Good evening. Can't add data to MSWord table. C ++ code:

Variant Word,Table,Cell,Document; AnsiString FilePath; FilePath = "C:\\Rasp.rtf"; Word = CreateOleObject("Word.Application"); // ΠΎΡ‚ΠΊΡ€Ρ‹Π²Π°ΡŽ Word. Word.OlePropertySet("Visible", true); // дСлаю Π²ΠΈΠ΄ΠΈΠΌΠΎΡΡ‚ΡŒ Π΄ΠΎΠΊΡƒΠΌΠ΅Π½Ρ‚Π°. // И Ρ‡Ρ‚ΠΎΠ±Ρ‹ Π½Π΅ ΡΠΎΠ·Π΄Π°Π²Π°Ρ‚ΡŒ Π½ΠΎΠ²Ρ‹ΠΉ лист, Π½Π°ΠΏΡ€ΠΈΠΌΠ΅Ρ€ (Word.OlePropertyGet("Documents").OleProcedure("Add"); ) ΠΎΡ‚ΠΊΡ€Ρ‹Π²Π°ΡŽ ΡƒΠΆΠ΅ созданный Π½Π° дискС Π‘:\ Π΄ΠΎΠΊΡƒΠΌΠ΅Π½Ρ‚ Ρ„ΠΎΡ€ΠΌΠ°Ρ‚Π° rtf, ΡƒΠΆΠ΅ с Π³ΠΎΡ‚ΠΎΠ²ΠΎΠΉ ΠΎΡ‚Ρ„ΠΎΡ€ΠΌΠ°Ρ‚ΠΈΡ€ΠΎΠ²Π°Π½Π½ΠΎΠΉ Ρ‚Π°Π±Π»ΠΈΡ†Π΅ΠΉ. Word.OlePropertyGet("Documents").OleFunction("Open", WideString(FilePath)); 

I do not know how to add data to the table cell? In general, you can add data to an already created table? How many examples viewed. Everything is just for the beginning of create and then perform any action.

    1 answer 1

    I've done everything. The code is of course honestly styled from another forum, but I understood what I did. In the finished table, where exactly it is necessary to insert the text, wrote a letter. Then selected it and went to the tab insert-> bookmark, gave the name to the bookmark and added.

     Variant vApp,vDocs, vDoc, vBookmarks, vBookmark, vSelection, vRange; AnsiString FilePath,str; FilePath = "C:\\Rasp.rtf"; vApp = CreateOleObject("Word.Application"); vApp.OlePropertySet("Visible", true); vDocs = vApp.OlePropertyGet("Documents"); vDocs.OleFunction("Add", WideString(FilePath)); vDoc = vDocs.OleFunction("Item",1); vDoc.OleProcedure("Activate"); vBookmarks = vDoc.OlePropertyGet("Bookmarks"); vBookmark = vBookmarks.OleFunction("Item", WideString("zakla")); // имя Π·Π°ΠΊΠ»Π°Π΄ΠΊΠΈ vBookmark.OleProcedure("Select"); vSelection = vApp.OlePropertyGet("Selection"); vSelection.OlePropertySet("Text", WideString("Козлов АндрСй")); // вставляСмый тСкст vRange = vDoc.OleFunction("Range", 0, 0); vRange.OleProcedure(_T("Select")); 

    Just in case the library:

     #include <OleServer.hpp> #include <ComObj.hpp> #include <utilcls.h>