Stop Word Creating Temp Files

C

colin.steadman

I've created an automated template that reads a list of employee
numbers from a text file and splits them into an array. It then loops
though the array and uses a number of functions and SQL calls to build
up a standard document. When all the data has been collected it uses
this code to save the document to a file:

ActiveDocument.SaveAs FileName:=EMPLOYEE_NUMBER & ".doc",
AddToRecentFiles:=False, FileFormat:=wdFormatDocument

This all works perfectly, but I've jut noticed that although only the
last document to be created is available in Word, there are all these
~$nnnnnn.doc in the save directory (presumably temp files).

How can I close/disconnect these file when I save each document as I
presume they are taking up resources and the real job will involve
thousands of employees, not just the hundred or so I'm testing with.

Thanks,

Colin
 
D

Doug Robbins

An ActiveDocument.Close should cause the temp files to be deleted.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
J

Jay Freedman

Hi Colin,

See http://support.microsoft.com/?kbid=211632 for an explanation of the temp
files that Word uses. The ones that start with ~$ are "owner files", which
you'll find explained about 2/3 of the way down the article.

These are not "using resources" other than a small amount of disk space.
They *should* be deleted automatically as soon as the corresponding document
is closed, but I can believe that this step could be delayed until Word
shuts down completely, if it's busy with other processes. In the case of a
crash, they can be orphaned -- see
http://www.gmayor.com/what_to_do_when_word_crashes.htm.
 
C

colin.steadman

Ahh, so thats what they are.

I think I'll just leave the template as it is then as I've already
tried the ActiveDocument.Close route, but that stopped all the
remaining documents from being created.

Thank you!

Colin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top