PDA

View Full Version : Solved: File Permission Error during Save



Doorman2006
10-15-2006, 08:38 AM
I am repeatedly saving a one-line Word document with several other large documents open (ActiveDocument.Save). I need to do this save several thousand times. After less than 1000 saves, I get Runtime Error 5487, file permission error and the document is not saved. I can debug and execute the Save manually. If I try to restart the macro, it will fail again. I am using Word 2003. This problem didn't occur with Word 2000. Any ideas or solutions?

mdmackillop
10-15-2006, 05:37 PM
Hi Doorman
Welcome to VBAX
Can you explain why you're doing this?
Meantime, if you need copies of a file you could try something like

Sub MakeCopies()
Dim fs, i as long
Set fs = CreateObject("Scripting.FileSystemObject")
For i = 1 To 2000
fs.CopyFile "c:\aaa\report.doc", "c:\aaa\Rep" & i & ".doc"
Next
End Sub


substituting different folders or whatever is required.

Doorman2006
10-15-2006, 07:11 PM
I am comparing 2 versions of a large table-based document to create a document showing revisions. I do a row-by-row copy to 2 documents and use the document compare method. While one document is the ActiveDocument in the Compare, the second has to be a saved document. (ActiveDocument.Compare Name:= "saved file"). In the "saved file" I repeatedly paste one row, save, compare, copy & paste to the Revision document and then delete the row. The current documents I am having problems with contains 9000 rows.:dunno

fumei
10-17-2006, 01:23 AM
Yikes!!!!

Could you step-by-step describe this again. Describe it in the smallest possible steps you can.

Surely there has to be a better way of doing this.
Word is not the best memory manager, which is possibly the culprit here.

Doorman2006
10-17-2006, 07:17 PM
I noticed that closing the "saved file" after a failure took 20 to 30 seconds. I tried periodically closing the "saved file" and then reopening it in the Macro. This eliminated the problem. Likely memory built-up. Thanks for your response.

fumei
10-18-2006, 11:07 AM
If you feel it is solved, could you make your thread as "Solved". Thanks.