Hello,
I have a question. When I open up Word 2007, I would like all the
files I have been working on to open automatically. Can this be done?
I would appreciate any help.
-Noah Walter
Word doesn't have any built-in facility like that, but it would be
fairly easy to build a pair of macros to handle it.
The first macro would save a list of the full path\filenames of the
currently open files to a text document in a known location. You could
assign this macro to a toolbar button and/or a shortcut key to run it
manually, or you could name it AutoExit to make it run automatically
when Word shuts down.
The second macro would read the text file from its known location and
attempt to open each file whose name it finds there. You could create
a desktop shortcut that includes the /m command-line switch to run
this macro at Word's startup (giving the possibility to start Word
without running the macro), or name the macro AutoExec so that it runs
on every startup.
Here are very simple versions of the macros.
Sub SaveFileList()
Const SaveFile = "C:\WordFileList.txt"
Dim oDoc As Document
Open SaveFile For Output As #1
For Each oDoc In Documents
If oDoc.Path <> "" Then
Print #1, oDoc.FullName
End If
Next
Close #1
End Sub
Sub OpenFileList()
Const SaveFile = "C:\WordFileList.txt"
Dim Fname As String
On Error Resume Next
Open SaveFile For Input As #1
If Err.Number <> 0 Then GoTo BadFile
Do While Not EOF(1)
Line Input #1, Fname
Documents.Open FileName:=Fname
If Err.Number <> 0 Then
MsgBox "Could not open " & Fname
Err.Clear
On Error Resume Next
End If
Loop
Exit Sub
BadFile:
MsgBox "The file " & SaveFile & " could not be opened."
End Sub
For "production" use, the error trapping should be improved.