General discussion

Locked

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.

4 total posts (Page 1 of 1)  
| 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 cdaringer@yahoo.com and I'll slip you some code...

you get yer own sdk.

Collapse -

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

Is this what you are looking for?

http://www.vbcode.com/asp/showzip.asp?ZipFile=http%3A%2F%2Fwww%2Earabteam2000%2Ecom%2Fprog%2Fbadwi%2FPDFReader%2Ezip&theID=4365

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.

Regards

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"

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

Back to Windows Forum
4 total posts (Page 1 of 1)  

Related Discussions

Related Forums