Resting Anchor

The Anchorage

Personal website of Gregory K. Maxey, Commander USN (Retired)

Group File Opener
(A Microsoft Word Help & Tip page by Gregory K. Maxey)

DISCLAIMER/TERMS OF USE

The information, illustrations and code contained in my "Microsoft Word Tips" are provided free and without risk or obligation.

Click to acces PayPal Verification Service Click to acces PayPal Verification Service

However, the work is mine. If you use it for commercial purposes or benefit from my efforts through income earned or time saved then a donation, however small, will help to ensure the continued availability of this resource.

If you would like to donate, please use the appropriate donate button to access PayPal. Thank you!

Click to donate British Pound Sterling                   Click to donate US dollars                   Click to donate EU euros

This Microsoft Word Tips & Microsoft Word Help page is one of my earliest offerings that has held its value. 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.

Start with all files in your group opened. The first macro saves all open files

VBA Script:
Sub GroupSave()
  Documents.Save NoPrompt:=True
lbl_Exit:
  Exit Sub

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

VBA Script:
Sub CloseFilesAndStoreList()
Dim strSettingsFile As String
Dim oDoc As Document
  strSettingsFile = Options.DefaultFilePath(wdDocumentsPath) & "\GroupFileList.txt"
  Open strSettingsFile For Output As #1
  For Each oDoc In Documents
    Print #1, oDoc.FullName
    oDoc.Close wdSaveChanges
  Next
  Close #1
End Sub

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

VBA Script:
Sub OpenListOfFiles()
Dim strSettingsFile As String
Dim arrFiles() As String
Dim i As Long
  strSettingsFile = Options.DefaultFilePath(wdDocumentsPath) & "\GroupFileList.txt"
  Open strSettingsFile For Input As #1
  arrFiles() = Split(Input(LOF(1), #1), vbCrLf)
  Close #1
  For i = 0 To UBound(arrFiles) - 1
    Documents.Open arrFiles(i)
  Next
lbl_Exit:
  Exit Sub
End Sub

I have provided a simple template add-in with a toolbar. Once you have intially 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.

group file opener 1

That's it! I hope you have found this tips page informative and you find the template add-in useful. Download the add-in here: Group File Opener

Site Note icon For more on template add-ins and how to load them, see: Organizing Your Macros/Template Add-ins at: Installing Macros

Share

DISCLAIMER/TERMS OF USE

The information, illustrations and code contained in my "Microsoft Word Tips" are provided free and without risk or obligation.

Click to acces PayPal Verification Service Click to acces PayPal Verification Service

However, the work is mine. If you use it for commercial purposes or benefit from my efforts through income earned or time saved then a donation, however small, will help to ensure the continued availability of this resource.

If you would like to donate, please use the appropriate donate button to access PayPal. Thank you!

Click to donate British Pound Sterling                   Click to donate US dollars                   Click to donate EU euros

Search my site or the web using Google Search Engine

Google Search Logo