LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with opening Word documents and with using bookmarks

Hi, my problems: (MS Word 2003, CVI 8.0.1)
 1]
 I open the existing sample.doc file (as template), which contains 4 bookmarks:
 
  caErrChk ( WordRpt_ApplicationNew (1, &appHandle));
  caErrChk ( WordRpt_DocumentOpen (appHandle,"c:\\sample.doc",&docHandle));
 
this is all ok, but then I want to jump to the first bookmark and start writing :
 
caErrChk (WordRpt_GoToBookmark (docHandle,"description"));
for (n=0;n<=40;n++) { caErrChk (WordRpt_AppendLine (docHandle, "Description")); }    // only for testing, writes 40 lines - fill out one column
 
and after this, CVI opens the Word, then loads sample.doc and that's all, no jump to the bookmark.
 
If I add before GoToBookmark fnc this:   caErrChk ( WordRpt_AppendLine (docHandle, "AA"));
then GoTo fnc is working well. (but in the final saved document the string "AA" is NOT written !)
 
2]
Original sample.doc (one empty table and one company stamp in the right bottom corner there)  has only one page. If I fill out the table and save the document, it has 3 pages (the first is epmty, on the second one is my corectly filled table and the third is also empty). Sometimes also Word saves the document with some chaotic strings, but only in minor case.
 
So pls, is here some compatibility problem (Word2000.fp vs Word 2003) or am I doing something wrong in the opening sequence ?
( All these function are starting up from TestStand - Tools/Sequence File Documentation (I am modifyind the docgen.dll) )
 
Thanks
               PetrM  - Czech. rep.

 
0 Kudos
Message 1 of 2
(3,174 Views)
Hi PetrM,

There shouldn't be any major compatibility problems with the Word2000.fp and Wodr 2003. You might try calling WordRpt_BookmarkExists before calling WordRpt_GoToBookmark just to see if it detecting that you have a bookmark in the Word document.

Does the "AA" get written anywhere in the document? You may have to use WordRpt_LinesMoveDown to get your cursor in the correct position as the documentation isn't clear if GoToBookmark moves the cursor position.

You might also consider using the example  [CVI version]\samples\activex\word and use that as a baseline for development as it provides more functionality than the wordreport.fp.


Test Engineer - CTA
0 Kudos
Message 2 of 2
(3,155 Views)