03-31-2011 10:49 AM
I have a macro routine that intensively plots a screen and copies the image into a file (.bmp). The macro routine keeps repeating for about 15 - 20 screen shots (images). Then the macro routine opens MSWord to insert all the pictures into a word document. For the fist time running the program, I can go through all the plotting, saving images, open up the word, insert the pictures into word with no problem. However, when I run for the second time (withouth exiting the program and re-execute the program), the plotting routine will crash. I troubleshooted the problem and found out that if I did not open the MS word
( CNiWordApplication application;
CNiWordDocument document = application.CreateDocument(); )
Then the software can run repeatively without the plotting routine crashing. However, if I create a document and did not go through the inserting the images, the software will crash on the plotting routine on the next run. Is there anything I should be aware of when I declare CNiWordApplication application; ? I am at my wits end here and our client is not very happy.
I will appreciate your helps.
Yajai.
04-01-2011 05:23 PM
Hi Yajai,
The first thing I would suggest is checking out this article that covers the basics of using the Microsoft Word Automation Interfaces.
Just to clarify -- when you run the program the first time, it executes as it should. When you run it again, however, it will crash during the plotting/saving process. Would you mind posting a screen shot of the error message you have been seeing? Also, what do you mean when you say you create a document but don't insert the images? Are there times in the program when it does not insert all of the images it captures in the Word document?
Regards,
Stephanie R.
National Instruments