LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Issue when trying to save a newly created Word document

I am using the Word feature in Labwindows to create test report
documents at the end of a functional test cycle. At the end of the
function that I call to create the report, just before it returns to
the calling routine, Labwindows stops in the "WordRpt_DocumentSaveAs"
function that I called, very similar to a breakpoint (which I didnt
set). I can hit the continue button and it finishes creating and
saving the Word report. I found that if I comment out the following
line in the "WordRpt_DocumentSaveAs" function, it doesnt stop, but I
have trouble opening the newly created Word document unless I wait a
while or exit the Labwindows program.

My code snippet of the call to save the Word document:
// save the report and close the application
WordRpt_DocumentSaveAs (gDocHandle, fileName); // save the document
WordRpt_ApplicationQuit (gAppHandle, WRConst_DoNotSaveChanges); //
close the application
return 0;

Code snippet of the "WordRpt_DocumentSaveAs" function (located in the
WordReport.c module) showing the "CA_VariantClear (&vtfileName)" line
of code, where Labwindows stops, very similar to setting a
breakpoint. :

HRESULT CVIFUNC WordRpt_DocumentSaveAs(CAObjHandle docHandle,
char
fileName[MAX_PATHNAME_LEN])
{
HRESULT error = S_OK;
VARIANT vtfileName;

CA_VariantSetEmpty (&vtfileName);

errChk (CA_VariantSetCString (&vtfileName, fileName));
errChk(Word_DocumentSaveAs (docHandle, NULL, vtfileName,
CA_DEFAULT_VAL,
CA_DEFAULT_VAL, CA_DEFAULT_VAL,
CA_DEFAULT_VAL,
CA_DEFAULT_VAL, CA_DEFAULT_VAL,
CA_DEFAULT_VAL,
CA_DEFAULT_VAL, CA_DEFAULT_VAL,
CA_DEFAULT_VAL));
Error:
// CA_VariantClear (&vtfileName); (THIS IS WHERE THE PROGRAM
STOPS, BUT DOESNT STOP WITH
THIS LINE
COMMENTED OUT)
return error;
}

Has anyone run across this issue/behavior or have any idea as to why
this is happening?

0 Kudos
Message 1 of 2
(2,983 Views)
0 Kudos
Message 2 of 2
(2,968 Views)