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!

Macro to BackUp File in Word 2000

Status
Not open for further replies.

Ben1637

Instructor
Nov 13, 2002
50
US
Hi Everybody:

I am trying - and failing - to create a macro that will:
1.) save the file I'm working on to the A:\ drive (i.e. create a backup of the file)
2.) Return to the file where I was working on it (i.e. File --> Save As again and switch back to the file on, say, the G:\ drive)

This is a pretty straight forward macro in terms of creating it for one particular file, but I'm wondering if there is a way to make it generic? In other words, when it does the File --> Save As, is there a way to write the macro so it keeps the name of the active file, rather than hard-coding a file name? For example, in the macro below, which accomplishes what I'm trying to do for one file, it uses the name "test.doc"...is there a way to modify this macro so it keeps the name of the active file and doesn't try to rename it to test.doc...in other words, is there a way to modify this macro so it will work for every file, not just test.doc?

Macro to BackUp test.doc:

Sub Macro2()
'
' Macro2 Macro
' Macro recorded 1/5/2005 by
'
ChangeFileOpenDirectory "A:\"
ActiveDocument.SaveAs FileName:="test.doc", FileFormat:=wdFormatDocument, _
LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword _
:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
False
ChangeFileOpenDirectory "G:\"
ActiveDocument.SaveAs FileName:="test.doc", 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!
 
Where you have ActiveDocument.SaveAs FileName:= "test.doc",

change all instance of that to

ActiveDocument.SaveAs FileName := ActiveDocument.Name
 
Thanks SO MUCH, YoungCougar!!!!
It worked perfectly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top