[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Open a pdf file from a local drive using Adobe Acrobat Reader using OLE object.

Posted on 2004-11-12
6
Medium Priority
?
2,826 Views
Last Modified: 2013-12-03
Hi,

We are using the Brio reporting software and I have a command button which when clicked will tell Brio to export the report in pdf format to the c drive. I can use the Application.Shell(App, Agrs) method to open Adobe Acrobat Reader and the saved pdf file from the C drive. Hoever this requires me to hard code the path to the AcroRd32.exe and this is a problem as different users may have different Adobe Reader versions. Thus I am trying to open Acrobat Reader using OLE object and am able to open it using the following two commands :
adobe = new OLEObject("AcroExch.App");
adobe.Show;

However I am unable to tell it to get the test .pdf file form C:\Test.Pdf and display it.

Can anybody please tell me how I can do this.

Thanks
0
Comment
Question by:sbatada
3 Comments
 
LVL 28

Accepted Solution

by:
vinnyd79 earned 1000 total points
ID: 12571118
Have you tried shellexecute api:

Private Declare Function ShellExecute Lib "shell32.dll" 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 Sub Command1_Click()
Call ShellExecute(hwnd, "Open", ("C:\Somefile.pdf"), "", "", 1)
End Sub
0
 
LVL 3

Expert Comment

by:4ceReconSniper
ID: 12571649
yeah that is the same way i did and i agree to his solution, but the acrobat.exe is left in the processes bar on yout task manager, ask vinnyd79 how to close it
0
 
LVL 4

Assisted Solution

by:rdwillett
rdwillett earned 1000 total points
ID: 12601048
Try this:
Create a new vb exe project
Add a form
Add a command button named Command1 (default name)
use the following code

Private Declare Function FindExecutable _
    Lib "shell32.dll" Alias "FindExecutableA" _
    (ByVal lpFile As String, _
    ByVal lpDirectory As String, _
    ByVal lpResult As String) As Long


Public Sub runappfile()
    Dim strname As String
    Dim strResult As String
    Dim lngResult As Long
    Dim i, s_msg
    On Error GoTo err_exitfunction
    strname = "C:\instructions.pdf"  '-----------------> put your filename here
    strResult = String(255, 0)
    lngResult = FindExecutable(strname, vbNullString, strResult)
    strResult = Trim(Replace(strResult, "/dde", "", 1))
    'run the file and not an .exe file
    i = Shell(Trim(Replace(strResult, vbNullChar, "", 1)) & " " & strname, 1)
    Exit Sub
   
err_exitfunction:
    MsgBox Err.Description, vbInformation, "Error Open Association"
    Exit Sub
End Sub

Private Sub Command1_Click()
    runappfile
End Sub
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Suggested Courses
Course of the Month18 days, 10 hours left to enroll

834 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