Home > Software engineering >  Word document write problem
Word document write problem

Time:10-15

A thread in the program to open the word document to write operation, the word document is not created in the program, but manually create (so don't know in the program file name, file path), in the program is running, a thread need to be able to detect the file, and the write data at the cursor position,

Consult everybody, how to detect the files in the thread, and the write data at the cursor position,

CodePudding user response:

If a word has been opened, regardless of his position, as if can directly write to, the cursor position to the demand did not know how to do

CodePudding user response:

Consult, this how to write

CodePudding user response:

If you need to finish writing the word operation, the simplest way is to create a template file myTemplate beforehand. The doc
Open it and then write operation, finally SaveAs (" export_name. Doc "), all of the operations function only through a smart pointer class contains,

According to my past experience, if we can only open the template file, execute the write operation, and then exit without save or save as, nothing happens,
So write to the target file should be in the cache, and is an OLE process control, such as at stow-on-the-wold. Exe process, want to through other ways, to determine the location file name of what, should can't positioning,

As for the cursor in what position, how to move the cursor, this can try ourselves in VBA, but are also relevant interface functions within OFFICE automation, the original poster can consult the relevant passages in the MSDN online documentation

CodePudding user response:

GetGUIThreadInfo () this can get the caret is located the HWND of the window handle, do not know is not for you?
Decide the HWND as part of the word, you can directly use the way of the clipboard to paste into the word document, now the data in the clipboard, and then simulate the CTRL + v button,
  • Related