I have these 2 codes and really they're not the best. What I'm trying to achieve is that I would like to run a macro in Microsoft Publisher then a input box pops up and all I have to do is to enter the file name and it should automatically open the file. I have these 2 codes but neitheris seems to work.

I'll appreciate with any suggestions.


VB Code:
  1. Sub Test1()
  2.     Dim pubApp As New Publisher.Application
  3.     Dim pubDocument As Publisher.Document
  4.      
  5.     myFile = InputBox _
  6.     ("Enter the Word document file name:", _
  7.     "What File do you wish to open?", _
  8.     "YourFileName")
  9.     If myFile = "" Then Exit Sub
  10.      
  11.     pubDocument = pubApp = "C:\.pub"
  12.      
  13.     If Dir(myDoc) = "" Then
  14.         MsgBox "The file ''" & myDoc & "'' was not found.", 48, "No such animal."
  15.         Exit Sub
  16.     End If
  17.      
  18. End Sub

VB Code:
  1. Sub Test1()
  2.     Dim myFile$
  3.     myFile = InputBox _
  4.     ("Enter the Word document file name:", _
  5.     "What File do you wish to open?", _
  6.     "YourFileName")
  7.     If myFile = "" Then Exit Sub
  8.      
  9.     Dim myPath$, myDoc$
  10.     myPath = "C:\Your\File\Path\"
  11.     myDoc = myPath & myFile & ".pub"
  12.      
  13.     If Dir(myDoc) = "" Then
  14.         MsgBox "The file ''" & myDoc & "'' was not found.", 48, "No such animal."
  15.         Exit Sub
  16.     End If
  17.      
  18.     Application.Open myDoc
  19.      
  20. End Sub