using macros to save to two locations

D

DrMarsha

I referenced the site gmayor.com but can't seem to get the macro to run
successfully...I think I am missing a step. When I click on the Macro on the
toolbar, I get the message:

Microsoft Visual Basic
Run-time error '5152':
This is not a valid file name.
Try one or more of the following:
*Check the path to make sure it was typed correctly.
*Select a file from the list of files and folders.

With the choices of End, Debug, or Help.

Can anyone see what I am doing wrong? I am trying to do a "true" backup of a
document in two different file locations. thanks.
 
J

Jay Freedman

I referenced the site gmayor.com but can't seem to get the macro to run
successfully...I think I am missing a step. When I click on the Macro on the
toolbar, I get the message:

Microsoft Visual Basic
Run-time error '5152':
This is not a valid file name.
Try one or more of the following:
*Check the path to make sure it was typed correctly.
*Select a file from the list of files and folders.

With the choices of End, Debug, or Help.

Can anyone see what I am doing wrong? I am trying to do a "true" backup of a
document in two different file locations. thanks.

Did you change the path that Graham shows in blue to a path that actually exists
on your computer? If you don't have a D: drive, or if the folder D:\My
Documents\Word Backup doesn't exist, then the file can't be saved there.
 
S

StevenM

Also, when you concatenated the path and filename, did you add the path
seperator? (It is an easy thing to overlook.)

Steven Craig Miller
 
D

DrMarsha

That was it; thanks! One other thing...do you still need to click on the
Macro to save the file in the other location? I was hoping that with one
click, it would save to the original file location as well as the macro
back-up, but this still seems like you need to click twice (one on save one
on macro) to save it? What really is the difference with this as compared to
just saving it to two different locations with the Save feature and not the
macro??? Thanks!
 
G

Graham Mayor

The macro from my web site

Sub SaveToTwoLocations()
Dim strFileA As String
Dim strFileB As String
Dim strFileC As String
ActiveDocument.Save
strFileA = ActiveDocument.Name
'Define backup path shown in blue below
strFileB = "D:\My Documents\Word Backup\Backup " & strFileA
strFileC = ActiveDocument.FullName
ActiveDocument.SaveAs FileName:=strFileB
ActiveDocument.SaveAs FileName:=strFileC
End Sub

saves the document with its original name and location (and gives the
opportunity to name an unsaved document) and saves a second copy in the
folder shown in blue i.e. D:\My Documents\Word Backup\ and appends "Backup
" to the start of the filename. If the backup location is removable media,
use the appropriate alternative macro from the same web page.


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
D

DrMarsha

Thank you..didn't realize save to both places was built in...is there a maco
such as this for Power Point and Excel as well? If so, might you direct me to
that macro?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top