Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variation of BackUp Macro Question in Word 2000

Status
Not open for further replies.

Ben1637

Instructor
Nov 13, 2002
50
US
Hi Everybody:

With your help, I was able to modify my macro so it:
1.) saves the file I'm working on to the A:\ drive (i.e. creates a backup of the file)
2.) Returns to the file where I was working on it (i.e. File --> Save As again and switches back to the file on, say, the H:\ drive)

I was able to get this macro to work so it keeps the active file's name (i.e. when it saves, it keeps the file's name, regardless of what it's called), but now I'm stuck with how to modify the macro so it keeps the active path. For example, if I'm working on a file that is saved in a subfolder on the H:\ drive, but next time I'm working on a file that is saved in the root of the H:\ drive, how can I modify my macro so it keeps, not only the active file's name, but it keeps the active file's path?

For example, in the macro below, is there a way to modify the second ChangeFileOpenDirectory to return to the directory the user was in prior to starting the macro (i.e. before the macro creates a backup of the file/switches to the A:\ drive)? In other words, as it stands now, the macro keeps the active document's name, but it will always save the file in step two to H:\training\Class Files\....how can I make the macro more generic so it saves files in the proper location (i.e. I don't want to hard code a path for this step, I want it to remember/reference the location prior to beginning the process). I hope this makes sense...

Here's what I have:

Sub SaveToDisk()

ChangeFileOpenDirectory "A:\"
ActiveDocument.SaveAs FileName:=ActiveDocument.Name, FileFormat:=wdFormatDocument, _
LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword _
:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
False
ChangeFileOpenDirectory "H:\training\Class Files\"
ActiveDocument.SaveAs FileName:=ActiveDocument.Name, FileFormat:=wdFormatDocument, _
LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword _
:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
False
End Sub


I would GREATLY appreciate any help and/or suggestions you may have.

Many thanks, in advance!
 
Try This

Sub SaveToDisk()
Dim origPath
origPath = ActiveDocument.Path


ChangeFileOpenDirectory "A:\"
ActiveDocument.SaveAs FileName:=ActiveDocument.Name, FileFormat:=wdFormatDocument, _
LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword _
:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
False
ChangeFileOpenDirectory origPath
ActiveDocument.SaveAs FileName:=ActiveDocument.Name, FileFormat:=wdFormatDocument, _
LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword _
:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
False
End Sub

Hope it helps!
 
FANTASTIC! Thank you VERY much for your help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top