PDA

Click to See Complete Forum and Search --> : Opening files


Sacha Rowland
Nov 4th, 1999, 11:01 AM
I need to open a file from my .exe file but it is application specific and I would like my exe file to open the application first and then open the file within the application. (It's a .pdf graphics file that needs to be opened in Acrobat Reader.)

Can anyone help?

Cheers!

Aaron Young
Nov 4th, 1999, 11:11 AM
There are two methods you can use:

Private Sub Command1_Click()
Shell Chr(34) & "C:\Program Files\Acroread\Acrord32.exe" & Chr(34) & " SomePDF.pdf", vbNormalFocus
End sub

Where Acrord32.exe is the Acrobat Reader EXE and SomePDF.pdf is the File and Path of the PDF you want to launch.

Or, more intuitively..

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()
ShellExecute 0&, "OPEN", "SomePDF.pdf", "", "", 1
End Sub

This method doesn't require you to know the location or name of the PDF Reader, as it launches the Associated EXE.


------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
adyoung@win.bright.net

Sacha Rowland
Nov 4th, 1999, 11:19 AM
Thanks.