Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.newusers
|
|||
|
|||
VBA, FileCopy instead of save to Flash Drive?
I am new to VBA, I have seen here and on other newsgroups that it is
unwise to save a word file directly to removeable media because of the various temp files created. Can I use Filecopy on a closed file instead? My snippet is below. I have used and modified the code from Graham Mayors site (http://www.gmayor.com/index.htm): Sub Backup() Dim strFileA, strFileB, strFileC, strFileD ActiveDocument.Save strFileA = ActiveDocument.Name ' backup file to different folder every other day If Even = (Day(Now) Mod 2) - 1 Then strFileB = "C:\Documents and Settings\Jim.DELL5150\My Documents\MyOddBackups\" & Format$(Now, "mmm d") & strFileA Else strFileB = "C:\Documents and Settings\Jim.DELL5150\My Documents\MyEvenBackups\" & Format$(Now, "mmm d") & strFileA End If strFileC = ActiveDocument.FullName ActiveDocument.SaveAs FileName:=strFileB ActiveDocument.SaveAs FileName:=strFileC ' after closing backup file, copy it to USB flash drive FileCopy strFileB, "F:\backups.doc" End Sub |
#2
Posted to microsoft.public.word.newusers
|
|||
|
|||
VBA, FileCopy instead of save to Flash Drive?
Copying files outside Word is OK, and I have written a macro that does just
that using FileCopy. It is the Save operation from Word that is dangerous on removable media. I may be wrong, being just a beginner, but that is my understanding. I will soon get shot down if I'm wrong. "jimc" wrote in message ups.com... I am new to VBA, I have seen here and on other newsgroups that it is unwise to save a word file directly to removeable media because of the various temp files created. Can I use Filecopy on a closed file instead? My snippet is below. I have used and modified the code from Graham Mayors site (http://www.gmayor.com/index.htm): Sub Backup() Dim strFileA, strFileB, strFileC, strFileD ActiveDocument.Save strFileA = ActiveDocument.Name ' backup file to different folder every other day If Even = (Day(Now) Mod 2) - 1 Then strFileB = "C:\Documents and Settings\Jim.DELL5150\My Documents\MyOddBackups\" & Format$(Now, "mmm d") & strFileA Else strFileB = "C:\Documents and Settings\Jim.DELL5150\My Documents\MyEvenBackups\" & Format$(Now, "mmm d") & strFileA End If strFileC = ActiveDocument.FullName ActiveDocument.SaveAs FileName:=strFileB ActiveDocument.SaveAs FileName:=strFileC ' after closing backup file, copy it to USB flash drive FileCopy strFileB, "F:\backups.doc" End Sub |
#3
Posted to microsoft.public.word.newusers
|
|||
|
|||
VBA, FileCopy instead of save to Flash Drive?
Yes you can use filecopy - I think the following is what you have attempted
to produce. Sub Backup() Dim strFileA As String Dim strFileB As String Dim strFlash As String ActiveDocument.Save 'save the original strFileA = ActiveDocument.Name 'saved original document name strFlash = "F:\" & strFileA 'flash drive filename ' backup file to different folder every other day If Even = (Day(Now) Mod 2) - 1 Then strFileB = "C:\Documents and Settings\Jim.DELL5150\MyDocuments\MyOddBackups\" & Format$(Now, "mmm d ") & strFileA Else strFileB = "C:\Documents and Settings\Jim.DELL5150\MyDocuments\MyEvenBackups\" & Format$(Now, "mmm d ") & strFileA End If ActiveDocument.SaveAs FileName:=strFileB 'save in the appropriate folder ' after closing backup file, copy it to USB flash drive ActiveDocument.Close 'close the document On Error GoTo oops FileCopy strFileA, strFlash 'Copy source to flash Documents.Open strFileA End oops: MsgBox "The copy drive is not available" Documents.Open strFileA End Sub -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org jimc wrote: I am new to VBA, I have seen here and on other newsgroups that it is unwise to save a word file directly to removeable media because of the various temp files created. Can I use Filecopy on a closed file instead? My snippet is below. I have used and modified the code from Graham Mayors site (http://www.gmayor.com/index.htm): Sub Backup() Dim strFileA, strFileB, strFileC, strFileD ActiveDocument.Save strFileA = ActiveDocument.Name ' backup file to different folder every other day If Even = (Day(Now) Mod 2) - 1 Then strFileB = "C:\Documents and Settings\Jim.DELL5150\My Documents\MyOddBackups\" & Format$(Now, "mmm d") & strFileA Else strFileB = "C:\Documents and Settings\Jim.DELL5150\My Documents\MyEvenBackups\" & Format$(Now, "mmm d") & strFileA End If strFileC = ActiveDocument.FullName ActiveDocument.SaveAs FileName:=strFileB ActiveDocument.SaveAs FileName:=strFileC ' after closing backup file, copy it to USB flash drive FileCopy strFileB, "F:\backups.doc" End Sub |
#4
Posted to microsoft.public.word.newusers
|
|||
|
|||
VBA, FileCopy instead of save to Flash Drive?
I have added a version of this macro with improved error handling to my web
site http://www.gmayor.com/automatically_....htm#removable -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Graham Mayor wrote: Yes you can use filecopy - I think the following is what you have attempted to produce. Sub Backup() Dim strFileA As String Dim strFileB As String Dim strFlash As String ActiveDocument.Save 'save the original strFileA = ActiveDocument.Name 'saved original document name strFlash = "F:\" & strFileA 'flash drive filename ' backup file to different folder every other day If Even = (Day(Now) Mod 2) - 1 Then strFileB = "C:\Documents and Settings\Jim.DELL5150\MyDocuments\MyOddBackups\" & Format$(Now, "mmm d ") & strFileA Else strFileB = "C:\Documents and Settings\Jim.DELL5150\MyDocuments\MyEvenBackups\" & Format$(Now, "mmm d ") & strFileA End If ActiveDocument.SaveAs FileName:=strFileB 'save in the appropriate folder ' after closing backup file, copy it to USB flash drive ActiveDocument.Close 'close the document On Error GoTo oops FileCopy strFileA, strFlash 'Copy source to flash Documents.Open strFileA End oops: MsgBox "The copy drive is not available" Documents.Open strFileA End Sub jimc wrote: I am new to VBA, I have seen here and on other newsgroups that it is unwise to save a word file directly to removeable media because of the various temp files created. Can I use Filecopy on a closed file instead? My snippet is below. I have used and modified the code from Graham Mayors site (http://www.gmayor.com/index.htm): Sub Backup() Dim strFileA, strFileB, strFileC, strFileD ActiveDocument.Save strFileA = ActiveDocument.Name ' backup file to different folder every other day If Even = (Day(Now) Mod 2) - 1 Then strFileB = "C:\Documents and Settings\Jim.DELL5150\My Documents\MyOddBackups\" & Format$(Now, "mmm d") & strFileA Else strFileB = "C:\Documents and Settings\Jim.DELL5150\My Documents\MyEvenBackups\" & Format$(Now, "mmm d") & strFileA End If strFileC = ActiveDocument.FullName ActiveDocument.SaveAs FileName:=strFileB ActiveDocument.SaveAs FileName:=strFileC ' after closing backup file, copy it to USB flash drive FileCopy strFileB, "F:\backups.doc" End Sub |
#5
Posted to microsoft.public.word.newusers
|
|||
|
|||
VBA, FileCopy instead of save to Flash Drive?
Graham Mayor wrote:
I have added a version of this macro with improved error handling to my web site http://www.gmayor.com/automatically_....htm#removable snip... Thank you Graham. |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
unable to save word 2003 on mapped drive | Microsoft Word Help | |||
Can't Save A File On A USB Drive | Microsoft Word Help | |||
Why is it not letting me save to E:/ drive? | Microsoft Word Help | |||
Can Not Save Word Docs on Network Drive | New Users | |||
access to my CD drive to save files | Microsoft Word Help |