A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Word » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Unique Backup Filename, Not



 
 
Thread Tools Display Modes
  #1  
Old May 29th, 2004, 03:45 AM
AA
external usenet poster
 
Posts: n/a
Default Unique Backup Filename, Not

I use Word's automatic backup feature, (OptionsSave
AlwaysCreateBackupCopy), which has saved me grief on more
than one occasion.

Lately I've been editing two documents at the same time,
named something like "Brown.Coverletter.May5.doc" and
"Brown.Summary.May5.doc". The problem is that the backup
file for each document is the same: "Backup of Brown.wbk",
because apparently all backup copies are named "Backup of
whatever precedes the first period in the filename.wbk".

Any clever VBA script to modify this behavior so that more
of the original filename is incorporated in the backup
filename? Or some other way to get unique backup copies in
this situation other than changing my file naming protocol?

TIA,

Andy



  #2  
Old May 29th, 2004, 06:56 AM
Jezebel
external usenet poster
 
Posts: n/a
Default Unique Backup Filename, Not

I think your file-naming protocol has to go. There's no obvious VBA way to
do it: Word's function for creating the backup filename is not exposed.
Changing your file naming will be a one-off nuisance, while any other
solution will be a permanent PIB. Just replace the periods with underscores
or spaces and your problem's gone.

Bear in mind, your problem isn't just with documents open simultaneously.
Your back-ups are getting overwritten anyway. You'll have only one back-up
file for *all* your Brown letters, containing whichever one you saved most
recently.



"AA" wrote in message
...
I use Word's automatic backup feature, (OptionsSave
AlwaysCreateBackupCopy), which has saved me grief on more
than one occasion.

Lately I've been editing two documents at the same time,
named something like "Brown.Coverletter.May5.doc" and
"Brown.Summary.May5.doc". The problem is that the backup
file for each document is the same: "Backup of Brown.wbk",
because apparently all backup copies are named "Backup of
whatever precedes the first period in the filename.wbk".

Any clever VBA script to modify this behavior so that more
of the original filename is incorporated in the backup
filename? Or some other way to get unique backup copies in
this situation other than changing my file naming protocol?

TIA,

Andy





  #3  
Old May 29th, 2004, 08:01 AM
Graham Mayor
external usenet poster
 
Posts: n/a
Default Unique Backup Filename, Not

You might find a macro to save in two separate locations useful - see
http://www.gmayor.com/automatically_backup.htm

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site www.mvps.org/word




AA wrote:
I use Word's automatic backup feature, (OptionsSave
AlwaysCreateBackupCopy), which has saved me grief on more
than one occasion.

Lately I've been editing two documents at the same time,
named something like "Brown.Coverletter.May5.doc" and
"Brown.Summary.May5.doc". The problem is that the backup
file for each document is the same: "Backup of Brown.wbk",
because apparently all backup copies are named "Backup of
whatever precedes the first period in the filename.wbk".

Any clever VBA script to modify this behavior so that more
of the original filename is incorporated in the backup
filename? Or some other way to get unique backup copies in
this situation other than changing my file naming protocol?

TIA,

Andy



  #4  
Old May 29th, 2004, 04:18 PM
Jay Freedman
external usenet poster
 
Posts: n/a
Default Unique Backup Filename, Not

Besides the convenience of Graham's macro, it's better than Word's
automatic "backup" because it really does give you a copy of the
latest version of the document -- something the automatic backup does
*not* do. See http://word.mvps.org/faqs/general/AutomaticSave.htm for
details.

"Graham Mayor" wrote:

You might find a macro to save in two separate locations useful - see
http://www.gmayor.com/automatically_backup.htm

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site www.mvps.org/word




AA wrote:
I use Word's automatic backup feature, (OptionsSave
AlwaysCreateBackupCopy), which has saved me grief on more
than one occasion.

Lately I've been editing two documents at the same time,
named something like "Brown.Coverletter.May5.doc" and
"Brown.Summary.May5.doc". The problem is that the backup
file for each document is the same: "Backup of Brown.wbk",
because apparently all backup copies are named "Backup of
whatever precedes the first period in the filename.wbk".

Any clever VBA script to modify this behavior so that more
of the original filename is incorporated in the backup
filename? Or some other way to get unique backup copies in
this situation other than changing my file naming protocol?

TIA,

Andy




--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://www.mvps.org/word
  #5  
Old May 29th, 2004, 05:14 PM
AA
external usenet poster
 
Posts: n/a
Default Unique Backup Filename, Not

You might find a macro to save in two separate locations useful - see
http://www.gmayor.com/automatically_backup.htm


Thanks Graham, I looked at this before, but it doesn't do what I want.

I need to save myself from flying fingers and momentary idiocy,
accidentally hitting Ctrl-S when the last thing I want is to save my
current file, overwriting the copy I really want. Word's automatic
backup feature works just fine for this.

I'm wondering if I could adapt the macro to do exactly what I want
though. It depends if there is a VBA command to copy a file.

Sub CallMyBackUpFileWhatIWantTo()
Dim strFileA, strFileB
strFileA = ActiveDocument.Name
strFileB = strFileA & ".baq"
is there a VBA command to copy strFileA to StrFilB?
Doing it in the current directory would be fine.
I could do that first, backing up the unsaved file,
then the next step would be to actually
save the current file:
ActiveDocument.Save
End Sub

An added benefit would be that my backup filename would look like
the original filename, and would sort better in Explorer.

What do you think?


Andy



  #6  
Old May 29th, 2004, 05:14 PM
AA
external usenet poster
 
Posts: n/a
Default Unique Backup Filename, Not


I think your file-naming protocol has to go. Changing your file
naming will be a one-off nuisance, while any other solution will
be a permanent PIB. Just replace the periods with underscores or
spaces and your problem's gone.


That would work, although I sometimes do command line stuff on all the
"Brown" documents, eg "copy Brown.*.*.* A:*.*.*.*.2003", or "dir
c:\*.summary.*/s". Not the most useful examples, but you get the idea.
Plus then I'd have a mixed batch of file-naming protocols unless I
went back and changed all my old files.


Bear in mind, your problem isn't just with documents open
simultaneously. Your back-ups are getting overwritten anyway.


That's ok, I'm diligent about backing up my work when I'm finished
each day anyway. When I need to keep iterations while I'm working, I
just right click and drag, and make a "Copy (n) of..".


You'll have only one back-up file for *all* your Brown letters,
containing whichever one you saved most recently.


That would be ok too, as long as I have one for *each* Brown document,
just while I'm working. I need to save myself from flying fingers and
momentary idiocy, accidentally hitting Ctrl-S when the last thing I
want is to save my current file, overwriting the copy I really want.
Word's automatic backup feature works just fine for this.


There's no obvious VBA way to do it: Word's function for creating
the backup filename is not exposed.


See my post to Graham, maybe there's a way to do what I want.



  #7  
Old May 29th, 2004, 10:20 PM
AA
external usenet poster
 
Posts: n/a
Default Unique Backup Filename, Not

Graham,

Here's what I figured out, seems to work ok:

Sub xBackupAndSave()
Dim strFileA, strFileB, fs
strFileA = ActiveDocument.Name
strFileB = strFileA & ".baq"
Set fs = CreateObject("Scripting.FileSystemObject")
fs.CopyFile strFileA, strFileB
ActiveDocument.Save
End Sub

It's now assigned to Ctrl-S. I still have Always Create Backup Copy
checked until I see if I run into problems.

Andy


  #8  
Old May 30th, 2004, 02:38 AM
Jezebel
external usenet poster
 
Posts: n/a
Default Unique Backup Filename, Not

You don't need the FileSystemObject for this. VBA's built-in FileCopy method
does the same thing.




"AA" wrote in message
...
Graham,

Here's what I figured out, seems to work ok:

Sub xBackupAndSave()
Dim strFileA, strFileB, fs
strFileA = ActiveDocument.Name
strFileB = strFileA & ".baq"
Set fs = CreateObject("Scripting.FileSystemObject")
fs.CopyFile strFileA, strFileB
ActiveDocument.Save
End Sub

It's now assigned to Ctrl-S. I still have Always Create Backup Copy
checked until I see if I run into problems.

Andy




  #9  
Old May 30th, 2004, 04:42 AM
AA
external usenet poster
 
Posts: n/a
Default Unique Backup Filename, Not

You don't need the FileSystemObject for this. VBA's built-in FileCopy method
does the same thing.


I tried FileCopy, but it doesn't work on an open file.

I don't even know what FileSystemObject is, but CopyFile wouldn't work without
it. The line of code defining fs,

Set fs = CreateObject("Scripting.FileSystemObject")

was something I copied from a help screen just to see if it would work,
typical of my way of stumbling around VBA using trial and error. Most of the
help screens make very little sense to me, I don't understand much of the
basic terminology.



  #10  
Old May 30th, 2004, 09:46 AM
Jezebel
external usenet poster
 
Posts: n/a
Default Unique Backup Filename, Not

'Scripting' refers to the Microsoft Scripting Runtime object. You're
currently using late binding to create a reference to it. You could use
early binding by adding Microsoft Scripting to the project's references
(VBA - Tools References), then instantiate the object using:

Dim fs as Scripting.FileSystemObject

set fs = New Scripting.FileSystemObject

A lot of experienced programmers have vehement objections to using this
object (check the VB forums for some seriously vitriolic discussions) mostly
on the grounds that it's unreliable, insecure, and unnecessary. Also, users
can disable it completely through the browser Internet options dialog.



"AA" wrote in message
...
You don't need the FileSystemObject for this. VBA's built-in FileCopy

method
does the same thing.


I tried FileCopy, but it doesn't work on an open file.

I don't even know what FileSystemObject is, but CopyFile wouldn't work

without
it. The line of code defining fs,

Set fs = CreateObject("Scripting.FileSystemObject")

was something I copied from a help screen just to see if it would work,
typical of my way of stumbling around VBA using trial and error. Most of

the
help screens make very little sense to me, I don't understand much of the
basic terminology.





 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 02:55 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.