?
Solved

Acc97 -Opening an adobe file through VB code

Posted on 2003-03-20
8
Medium Priority
?
430 Views
Last Modified: 2011-10-03
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\DirectoryName\FileName.doc")
    If Err.Number <> 0 Then MsgBox (Err.Description)
 
    Err.Clear
    oApp.Application.Visible = True
    oApp.Parent.Windows(1).Visible = 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\DirectoryName\FileName.pdf")
I get the following error message

     "ActiveX componet cannot create object"

How can I open a pdf file using VB code?


0
Comment
Question by:ncrew
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
8 Comments
 
LVL 18

Expert Comment

by:1William
ID: 8176543
How about using a shell command?
0
 
LVL 5

Accepted Solution

by:
Mike77 earned 1000 total points
ID: 8176563
Try this :

'declarations
------------------

Private Declare Function ShellExecute Lib "shell32" _
   Alias "ShellExecuteA" _
  (ByVal hwnd As Long, _
   ByVal lpOperation As String, _
   ByVal lpFile As String, _
   ByVal lpParameters As String, _
   ByVal lpDirectory As String, _
   ByVal nShowCmd As Long) As Long
   
Private Const SW_SHOWNORMAL As Long = 1
Private Const SW_SHOWMAXIMIZED As Long = 3
Private Const SW_SHOWDEFAULT As Long = 10
Private Const SE_ERR_NOASSOC As Long = 31

'code
---------
Call ShellExecute(0&, "open", "c:\path\file.pdf", 0&, 0&, SW_SHOWNORMAL)
0
 
LVL 18

Expert Comment

by:1William
ID: 8176570
Like this:
Dim RetVal

RetVal = Shell("C:\Program Files\Adobe\Acrobat 4.0\Reader\AcroRd32.exe" & " " & "\\ServerName\DirectoryName\FileName.pdf")
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

Author Comment

by:ncrew
ID: 8176572
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.
0
 
LVL 18

Expert Comment

by:1William
ID: 8176610
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\DirectoryName\FileName.pdf"
0
 
LVL 5

Expert Comment

by:Mike77
ID: 8176636
what if acrobat has not been installed in the default directory?
0
 

Author Comment

by:ncrew
ID: 8176659
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.
0
 

Author Comment

by:ncrew
ID: 8176662
I appreciatd the step-by-step solution!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question