Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open all WORD files in a folder

Status
Not open for further replies.

pete4505

Programmer
Dec 5, 2002
4
US
Is there a way to open all the WORD files in a folder without having to specify each by name?
 
This'll do it for you:

Code:
Sub OpenMultipleFiles()
Dim Filt As String, Title As String, Msg As String
Dim i As Integer
Dim FileName As Variant
Filt = "Word Dcuments (*.doc),*.doc,"
Title = "Select File(s) to Import"
FileName = Excel.Application.GetOpenFileName(FileFilter:=Filt, _
                            Title:=Title, MultiSelect:=True)
If Not IsArray(FileName) Then
MsgBox "No file was selected."
    Exit Sub
End If
For i = LBound(FileName) To UBound(FileName)
Documents.Open FileName(i)
Next i
End Sub

Don't worry about the Excel.Application part, it works for Word. I actually use this pretty often!

Enjoy!


Peace! [peace]

Mike

Never say Never!!!
Nothing is impossible!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top