![]() |
|
|
| Subject:
backing up word files using VBA
Category: Computers > Programming Asked by: shantanuo-ga List Price: $2.00 |
Posted:
20 Jun 2002 06:34 PDT
Expires: 23 Jun 2002 04:00 PDT Question ID: 29713 |
Hi Here is the simple macro I have recorded in Word. It creats a backup.doc file after inserting the contents of all the .doc files saved in My Documents. I can run it if I know the exact file name. But if I don't know the names of all the files, how can get the first word file, insert the contents, then grab the second one for backup. Sub Macro3() ' ' Macro3 Macro ' Macro recorded 04/06/02 by shantanu Documents.Add DocumentType:=wdNewBlankDocument ChangeFileOpenDirectory "C:\My Documents\" Selection.InsertFile FileName:="AGREEMENT OF LEAVE AND LICENCE.doc" Selection.InsertFile FileName:="elite.doc" ActiveDocument.SaveAs FileName:="backup.doc" End Sub Thanks Shantanu Oak | |
| |
|
|
| There is no answer at this time. |
|
| Subject:
Re: backing up word files using VBA
From: f1jeeves-ga on 20 Jun 2002 07:11 PDT |
Try this:
Sub Macro3()
'
' Macro3 Macro
' Macro recorded 04/06/02 by shantanu
Dim MyFile, MyDir
MyDir = "C:\My Documents\"
Documents.Add DocumentType:=wdNewBlankDocument
ChangeFileOpenDirectory MyDir
MyFile = Dir(MyDir & "*.doc")
While MyFile <> ""
Selection.InsertFile FileName:=MyFile
'Selection.InsertFile FileName:="doc4.doc"
MyFile = Dir
Wend
ActiveDocument.SaveAs FileName:="backup.doc"
End Sub |
| Subject:
backing up word files using VBA
From: shantanuo-ga on 20 Jun 2002 07:43 PDT |
lazerfx - yes you are right. f1jeeves - I want to include the sub-directories in my documents as well. AND Here is a request, though it was not a part of the question. Can I add the name of the document at the beginning of each text block? Thanks |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
| Search Google Answers for |
| Google Home - Answers FAQ - Terms of Service - Privacy Policy |