LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with wordreport.fp when Word is NOT visible

When wordreport.fp creates a new word doc with MS Word NOT visible ie.
WordRpt_ApplicationNew (VFALSE, &appHandle);
WordRpt_DocumentNew (appHandle, &docHandle);
then subsequent wordreport function calls appear to applied to the word document in a different sequence to the order that they are coded. As a result blocks of text and formatting are in the wrong places in the document. Simply changing the VFALSE to VTRUE makes the problem go away.
It was as if the Active X control commands were being sent to Word in the wrong order.
With VFALSE I single stepped through all of the code to generate the Word document and got exactly the same result.
I'm using CVI in Measurement Studio version 6.0 and MS Word 2000
What is going wrong? I havene't tried adding HRESULT = to see what the functions are returning but as I say, it all works fine with MS Word visible
0 Kudos
Message 1 of 3
(3,078 Views)
Hi!

I don´t use the wordreport.fp because their functions were not sufficient for my requirements. So I´m using directly the ActiveX interface of Word to create reports.
I had similar problems like you have described. For example, if I applied a new column width to a table, Word sometimes did it and sometimes it did not - independent of the state of visibility. After uncountable hours of trying it seemed to me, that Word or ActiveX is too slow to process the commands. So I add a delay of 0.2 up to 0.9 seconds after all ActiveX commands which didn´t work correctly. And now, all works fine.

Hope, this will help you!
regards
0 Kudos
Message 2 of 3
(3,071 Views)
Thanks. I'll try adding Delay(0.2)
I was thinking maybe delays would help but I expected that single stepping in debug mode would have fixed that but it gave same results.
0 Kudos
Message 3 of 3
(3,063 Views)