ncrew
asked on
Acc97 -Opening an adobe file through VB code
Here is my code that works when I want to open a Word Doc.
Dim oApp As Object
On Error Resume Next
Set oApp = GetObject(, "word.Application")
If Err.Number <> 0 Then MsgBox (Err.Description)
Err.Clear
Set oApp = GetObject ("\\ServerName\DirectoryNa me\FileNam e.doc")
If Err.Number <> 0 Then MsgBox (Err.Description)
Err.Clear
oApp.Application.Visible = True
oApp.Parent.Windows(1).Vis ible = True
Set oApp = Nothing
If I try to change the class to
Set oApp = GetObject(, "Acrobat.Application")
and the file name to
Set oApp = GetObject ("\\ServerName\DirectoryNa me\FileNam e.pdf")
I get the following error message
"ActiveX componet cannot create object"
How can I open a pdf file using VB code?
Dim oApp As Object
On Error Resume Next
Set oApp = GetObject(, "word.Application")
If Err.Number <> 0 Then MsgBox (Err.Description)
Err.Clear
Set oApp = GetObject ("\\ServerName\DirectoryNa
If Err.Number <> 0 Then MsgBox (Err.Description)
Err.Clear
oApp.Application.Visible = True
oApp.Parent.Windows(1).Vis
Set oApp = Nothing
If I try to change the class to
Set oApp = GetObject(, "Acrobat.Application")
and the file name to
Set oApp = GetObject ("\\ServerName\DirectoryNa
I get the following error message
"ActiveX componet cannot create object"
How can I open a pdf file using VB code?
How about using a shell command?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Like this:
Dim RetVal
RetVal = Shell("C:\Program Files\Adobe\Acrobat 4.0\Reader\AcroRd32.exe" & " " & "\\ServerName\DirectoryNam e\FileName .pdf")
Dim RetVal
RetVal = Shell("C:\Program Files\Adobe\Acrobat 4.0\Reader\AcroRd32.exe" & " " & "\\ServerName\DirectoryNam
ASKER
I'm open to suggestions, but I'll need "hand holding". I don't know what you mean by shell command or how to execute it.
Take my second suggestion and change the path information to suit. The first part is the path to acrobat
("C:\Program Files\Adobe\Acrobat 4.0\Reader\AcroRd32.exe"
and the second is to the PDF
"\\ServerName\DirectoryNam e\FileName .pdf"
("C:\Program Files\Adobe\Acrobat 4.0\Reader\AcroRd32.exe"
and the second is to the PDF
"\\ServerName\DirectoryNam
what if acrobat has not been installed in the default directory?
ASKER
Gentlemen, you're both my heros. I am selecting Mike's answer because the Adobe software resides on a server and I don't have the exact location; using his code, I did not need it.
Thank you both.
Thank you both.
ASKER
I appreciatd the step-by-step solution!