-
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!
-
There are two methods you can use:
Code:
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..
Code:
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
[email protected]
[email protected]
-