R
Rick
I have a macro that saves the currently opened file with
a new name and into a different directory. I then need it
to delete the original file. If I try to delete the
original before closing the renamed file, I get an error.
If I try to delete it after closing the renamed file,
it's as if the entire macro stops. The file is built on
the template that's used to create the document.
The macro runs and I get the 1st message box but not the
second.
Here's the code I'm using:
ChangeFileOpenDirectory FilePath 'Change to proper dir
ActiveDocument.SaveAs FullReportName,
FileFormat:=wdFormatDocument
On Error GoTo CleanUpErrorHandler
MsgBox ("Got Here 1")
ActiveDocument.Close ' closes currently opened file
MsgBox ("Got Here 2")
ChangeFileOpenDirectory Path
MsgBox (DelFile)
Kill DelFile ' deletes original file
End
a new name and into a different directory. I then need it
to delete the original file. If I try to delete the
original before closing the renamed file, I get an error.
If I try to delete it after closing the renamed file,
it's as if the entire macro stops. The file is built on
the template that's used to create the document.
The macro runs and I get the 1st message box but not the
second.
Here's the code I'm using:
ChangeFileOpenDirectory FilePath 'Change to proper dir
ActiveDocument.SaveAs FullReportName,
FileFormat:=wdFormatDocument
On Error GoTo CleanUpErrorHandler
MsgBox ("Got Here 1")
ActiveDocument.Close ' closes currently opened file
MsgBox ("Got Here 2")
ChangeFileOpenDirectory Path
MsgBox (DelFile)
Kill DelFile ' deletes original file
End