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.

Re: using macros to save to two locations by Jay

Jay
Wed Jun 18 17:59:54 PDT 2008

On Wed, 18 Jun 2008 15:01:01 -0700, DrMarsha
<DrMarsha@discussions.microsoft.com> wrote:

>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.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit.

RE: using macros to save to two locations by stevencraigmiller(at)comcast(dot)net>

stevencraigmiller(at)comcast(dot)net>
Wed Jun 18 18:56:01 PDT 2008

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

Steven Craig Miller

"DrMarsha" wrote:

> 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.

RE: using macros to save to two locations by DrMarsha

DrMarsha
Wed Jun 18 19:22:00 PDT 2008

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!

"StevenM" wrote:

> Also, when you concatenated the path and filename, did you add the path
> seperator? (It is an easy thing to overlook.)
>
> Steven Craig Miller
>
> "DrMarsha" wrote:
>
> > 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.

Re: using macros to save to two locations by Graham

Graham
Wed Jun 18 22:10:14 PDT 2008

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

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>


DrMarsha wrote:
> 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!
>
> "StevenM" wrote:
>
>> Also, when you concatenated the path and filename, did you add the
>> path seperator? (It is an easy thing to overlook.)
>>
>> Steven Craig Miller
>>
>> "DrMarsha" wrote:
>>
>>> 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.



Re: using macros to save to two locations by DrMarsha

DrMarsha
Thu Jun 19 05:22:02 PDT 2008

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?

"Graham Mayor" wrote:

> 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
>
> My web site www.gmayor.com
> Word MVP web site http://word.mvps.org
> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
>
>
> DrMarsha wrote:
> > 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!
> >
> > "StevenM" wrote:
> >
> >> Also, when you concatenated the path and filename, did you add the
> >> path seperator? (It is an easy thing to overlook.)
> >>
> >> Steven Craig Miller
> >>
> >> "DrMarsha" wrote:
> >>
> >>> 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.
>
>
>