Open a Group of Files

Home Up Odds & Ends Photo Gallery Search Contact Me

 

 

The information in this website is provided without risk or obligation and free of charge.  However, if you have benefitted from my efforts here and would like to make a contribution to help me continue and maintain this work then any donation will be greatly appreciated. Please click the adjacent button to access PayPal.  Thank you.
 

Do you often work with a group of say half a dozen files scattered across two or more folders?  The macros in this tips page will allow you to quickly save and close all of your group of files and then reopen the entire group with a click of a button anytime you want to work with that group of files again.

The first macro saves all open files:

 

Sub GroupSave()
     Documents.Save NoPrompt:=True
End Sub

 

The second macro writes the file name and path to a .txt file, saves, and finally closes the group of open files:

 

Sub CloseFilesAndStoreList()
Dim myFile As String
Dim SettingsFile As String
Dim myDoc As Document
SettingsFile = Options.DefaultFilePath(wdDocumentsPath) & "\MyFileList.txt"
Open SettingsFile For Output As #1
For Each myDoc In Documents
    Print #1, myDoc.FullName
    myDoc.Close wdSaveChanges
Next
Close #1
End Sub

 
The final macro opens all the files in a .txt file "MyFileList.txt" stored in your default documents folder: 
 

Sub OpenListOfFiles()
Dim SettingsFile As String
Dim myFile() As String
Dim i As Long
SettingsFile = Options.DefaultFilePath(wdDocumentsPath) & "\MyFileList.txt"
Open SettingsFile For Input As #1
myFile() = Split(Input(LOF(1), #1), vbCrLf)
Close #1
For i = 0 To UBound(myFile) - 1
    Documents.Open myFile(i)
Next
End Sub

 

I have attached a template with a toolbar that can be used as a Word Add-In.  Once you have opened your group of files "the old fashioned way," the toolbar can be used to save all the open files in your group, save and close the group, and reopen the group.

Inspiration for this tips page came from a fellow named Larry, who is a regular presence in the Word newsgroup.  Fellow MVPs Helmut Weber and Graham Mayor also helped by offering some coding tips.
The Add-In is provided here in a zip file format.  You can download "Open Group Files" to your Word Templates directory and load it using Tools>Templates and Add-Ins.  For more on Add-Ins and how to load them, see the heading "Organizing Global Templates" at:    Organizing Your Macros
Download "Group File Opener"

Looking for something else?Looking for something else?

Google