Discussion Locked

Use VB to launch file in assoc. program

0 helpful
4 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I'm sort of new to Visual Basic and I'm trying to figure out a way to open a PDF file in Acrobat Reader using Visual Basic. The Adobe site says that Reader does not allow automation, so you can't hook into it's object model. I was wondering if there was a way to launch a file and have it open in it's associated program. Sort of like when you double click a file in Explorer, or enter the file and path in the Start - Run dialog box. Do I have to use the API? Am I missing something? I tried looking for answers on many websites, but couldn't find anything that addresses this. I'm stumped!!! Thanks for your help!!

4 replies

by cdaringer

The adobe sdk uses an assync model. That means that the process is not deterministic. Sooo...
you create the process and then monitor it.

similar to ADO which is also assync in nature or disconected recordsets.

email me at cdaringer@yahoo.com and I'll slip you some code...

you get yer own sdk.

by manoj_india

If you only want to launch the pdf application just to view file then you can use Shell or ShellExecute.

If you want to monitor the file then you can use CreateProcess, so that you will get the Process Handle.

Regards

by mickeyf

Note: This is untested, and you'll need to make a function or subroutine out of the code. Also, REG_QueryValue is an encapsulation of RegOpenKeyEx, RegQueryValueEx and RegCloseKey. Look at your API help to figure that part out.

Dim AcrobatPath As String
Const ACROBATAPPPATHKEY = "SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\AcroRd32.exe"

AcrobatPath = REG_QueryValue(HKEY_LOCAL_MACHINE, ACROBATAPPPATHKEY, "", "")
If (AcrobatPath <> "") Then
Shell AcrobatPath + " " + Trim$(Command$), vbNormalFocus
Else
MsgBox "Adobe Acrobat Reader must be installed.", vbInformation
End If

This discussion is closed to new replies.