This is a great code. When you run this code in Microsoft Word it pops up a input box then I type the file name in the input box and it will open the word document file. I would like to use this code for Microsoft Publisher. Can this code be modified for Microsoft publisher ?
[VBA]
Sub Test1()
Dim myFile$
myFile = InputBox _
("Enter the Word document file name:", _
"What File do you wish to open?", _
"YourFileName")
If myFile = "" Then Exit Sub
Dim myPath$, myDoc$
myPath = "C:\Your\File\Path\"
myDoc = myPath & myFile & ".doc"
If Dir(myDoc) = "" Then
MsgBox "The file ''" & myDoc & "'' was not found.", 48, "No such animal."
Exit Sub
End If
Application.ScreenUpdating = False
Dim appWord As Object
Dim wdDoc As Object
Set appWord = CreateObject("Word.Application")
appWord.Visible = True
Set wdDoc = appWord.Documents.Open(myDoc)
Set wdDoc = Nothing
Set appWord = Nothing
Application.ScreenUpdating = True
End Sub
[/VBA]