1

我写了一个例程,它复制一个word文档并将其粘贴到c++中的一个新word文档中(Borland Builder 5)

tbSearch->Text = "{axis1[d]} ";
Variant vk_this_doc_select = wrdDoc1.OleFunction( "Select" );                // wir selektieren dessen Inhalt des geöffneten Dokuments
wordSelection = zuladendesDokument.OlePropertyGet("Selection");              // tun es in den ZwischenSpeicher der Applikation
wordSelection.OleFunction( "Copy" );                                        // und kopieren es
Variant vk_converted_document_select =  wrdDoc.OleFunction( "Select" );    // wir machen die Selektion im alten Dokument
Variant vk_converted_document_selection =   wrdApp.OlePropertyGet( "Selection" );
Variant  wordSelectionFind = vk_converted_document_selection.OlePropertyGet( "Find" );   // setzen den Zeiger
wordSelectionFind.OleFunction( "Execute", tbSearch->Text, false, false, false, false, false, true, 1, false, wordSelection, 2, false, false, false, false );

该例程运行良好,但在插入例程中,word 文档的图形部分被破坏了。

我也尝试通过

k_converted_document_selection.OleFunction( "PasteSpecial"), 0, false, 0, false, 0);

这里格式没问题,但是粘贴文件的位置不对(每次都在文件的开头。

所以我有两个问题:

  • 如何保存格式?
  • 如何将粘贴的word文档设置到正确的位置?

过了一会儿(失去了 2-10 个神经细胞fg)我自己得到了答案,所以我发布了下一个结果,处理这个问题(对不起我的英语不好)。希望任何人都可以使用它...

           tbSearch->Text = "{axis3[d]}" ;

            Variant vk_this_doc_select = wrdDoc1.OleFunction( "Select" );// select the contain of the document to be insert

            wordSelection = zuladendesDokument.OlePropertyGet("Selection"); // select

            wordSelection.OleFunction( "Copy" ); // copy

            Variant vk_converted_document_select =  wrdDoc.OleFunction( "Select" ); // select the first document 

            Variant vk_converted_document_selection =   wrdApp.OlePropertyGet( "Selection" );

           Variant  wordSelectionFind = vk_converted_document_selection.OlePropertyGet( "Find" );   

                                                                                      // now the trick with is the solution: find the position you want, but do nothing ("")
           wordSelectionFind.OleFunction( "Execute", tbSearch->Text, false, false, false, false, false, true, 1, false, "", 1, true, true, true, true );

           vk_converted_document_selection.OleFunction( "PasteSpecial", 0, false, 0, false, 0); // now the pointer in the document is found, means PasteSpecial will insert the document at the right place
4

0 回答 0