General discussion


Use VB to launch file in assoc. program

By yalbets ·
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!!

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -

uses assyn messaging

by cdaringer In reply to Use VB to launch file in ...

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 and I'll slip you some code...

you get yer own sdk.

Collapse -

Use ShellEecute

by manoj_india In reply to Use VB to launch file in ...

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.


Collapse -

VB code snipped to launch Acrobat Reader

by MickeyF In reply to Use VB to launch file in ...

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"

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

Related Discussions

Related Forums