Thread: [Solved] Clear document
View Single Post
 
Old 07-17-2011, 09:12 AM
Jaymond Flurrie Jaymond Flurrie is offline Windows 7 64bit Office 2010 32bit
Novice
 
Join Date: Feb 2011
Posts: 13
Jaymond Flurrie is on a distinguished road
Default Clear document

Hi,

This is next to "Hello World" for you who have programmed Word even a bit. Short and simply: How do I clear the document?

The bigger idea is that I'm importing data from Excel to Word and I used to have my flow going basically like this:
Create Word application
Create Word document
Select the header
Edit the header
Select the "main part" of document
Type text
{
Paste a chart
Enter PageBreak
}(Repeat five times)
Paste a chart
Print to PDF
Close the document without saving
Terminate the instance of Word

With six charts, forty documents it took about three minutes. Now I realized that it's pretty stupid to create the Word application and Word document from scratch over and over again. Smarter solution would be just to delete everything from the document and close/terminate it at the end. Sure, I could also create a new document each time, but since I don't need the docs (the only reason I use Word at all is that it compiles the document nicely), I don't know if it would be any faster to create a new document.

If you know for sure that just closing the old and creating a new document is faster than deleting the whole content is faster, please tell me.

Even better might be linking system ie. I create the document by pasting once and then updating the charts in Excel updates them in Word and then I take a printout. Is that possible?
Reply With Quote