Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.word.vba.general
external usenet poster
 
Posts: 120
Default Can't delete file?!!?

The error message was simply: "Method SaveAs of object Document not
available."

Aware that I'm using Excel VBA to run Word, I broke it up a bit into
objDoc.Save and then objDoc.Close.

The Save threw an error. I hit Debug, checked a variable, then hit F8
to run back over the line and get the error message. It ran the line
and continued on.

I'm assuming I've got some background processes on my machine that are
slowing down file operations. Maybe I've got too much going on in
this macro with Word, Excel, and FSO. Anyway, I wrapped the Save in a
loop like this:

x = 0
On Error Resume Next
Do
x = x + 1
objDoc.Save
If x = 6 Then
If objDoc.Saved = False Then
MsgBox "Doc won't save!"
Exit Do
End If
End If
Loop While objDoc.Saved = False

objDoc.Close wdDoNotSaveChanges

Saves just fine on the second time (so far), then closes and deletes.

So all is good. Glad I found this on my machine, because it would
have given me fits if it worked okay on mine but not for someone else.

Thank you, Jay and Chris, for the support.
Ed



On Apr 7, 1:28*pm, mcescher wrote:
On Apr 7, 1:42*pm, Ed from AZ wrote:

Further piddling shows that when I remove
* * objDoc.Close SaveChanges:=wdSaveChanges
from the On Error Resume Next, it throws an error.


So the file won't delete because it's still open. *That's solved.
Now - why won't it close??


I will continue playing - any helpful drop-kicks are always
appreciated.
Ed


So, what is the value of wdSaveChanges? *Is that a valid value for
SaveChanges? *Are there other required parameters that you're
missing? *Have you take the two Stop statements out?

Hope this helps,
Chris M.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to delete sheets and saves remaining file does not properly delete module pherrero Excel Programming 1 June 22nd 05 01:12 AM
Macro to delete sheets and saves remaining file does not properly delete module pherrero Excel Programming 0 June 21st 05 05:11 PM
Macro to delete sheets and saves remaining file does not properly delete module bhawane Excel Programming 0 June 21st 05 04:54 PM
Macro to delete sheets and saves remaining file does not properly delete module bhawane Excel Programming 0 June 21st 05 04:53 PM
Macro to delete sheets and saves remaining file does not properly delete module bhawane Excel Programming 0 June 21st 05 04:20 PM


All times are GMT +1. The time now is 02:24 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"