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:
Sub Test1() Dim pubApp As New Publisher.Application Dim pubDocument As Publisher.Document myFile = InputBox _ ("Enter the Word document file name:", _ "What File do you wish to open?", _ "YourFileName") If myFile = "" Then Exit Sub pubDocument = pubApp = "C:\.pub" If Dir(myDoc) = "" Then MsgBox "The file ''" & myDoc & "'' was not found.", 48, "No such animal." Exit Sub End If End Sub
VB Code:
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 & ".pub" If Dir(myDoc) = "" Then MsgBox "The file ''" & myDoc & "'' was not found.", 48, "No such animal." Exit Sub End If Application.Open myDoc End Sub


Reply With Quote