
Opening a PDF file w/o opening acrobat first
Ok, in the General Declarations section of your form, declare the API
function and the constants used. I'm assuming here that it's being done
from a form:
Private Const SW_SHOW = 5
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
In your Button_Click event, use this code:
If ShellExecute(me.hwnd, "open" & chr(0), App.Path & "\PDFFILENAME.PDF" &
chr(0), 0&, App.Path & chr(0), SW_SHOW) <= 32 then
Msgbox "Unable to launch adobe Acrobat"
End If
HOWEVER. You say this is going to be autorun from a CD. You are aware that
this won't work on any machine that doesn't already have the VB support
files, aren't you? Typically you have the use the Package and Deployment
Wizard to create a setup application for all VB apps.
Regards,
Jon Brierley
Quote:
----- Original Message -----
Sent: September 12, 1999 5:23 PM
Subject: Re: Opening a PDF file w/o opening acrobat first
> Jon,
> I am just getting into this VB programing field therefore im a rookie.
> Im not too familar on how to do the ShellExecute function... Someone gave
me
> some code in the newsgroup but i cant get it working...i have tried
> everything.
> All i want to do is have the file opened, i dont need any integration or
> anything. I just want it to open the file in Acrobats Window and not in
> another form window in the VB program. This App that im making is a
Autorun
> file and i have buttons. I want to click on the button and have it launch
> this pdf file....
> If you could give me some VB code or send me to some place that can show
me
> how to do this better i would be so greatful.
> Thank you,
> Ryan
> > It shouldn't matter where Acrobat was installed to. The system knows.
If
> > you use the ShellExecute API function rather than the VB Shell function,
> it
> > will automatically start Acrobat based on the systems file type
> registration
> > information.
> > You could try using the Acrobat ocx control if you want real integration
> in
> > VB. It's included with the Acrobat reader and should show up in your
> > Project/Controls... menu option. I *think* it's distributable, but
> you'll
> > have to check with Adobe to be sure.
> > Jon Brierley
> > Engineering Software Developer
> > Armtec
> > > I wanna have a button that will open a file using the directly not
have
> to
> > > open acrobat then open the pdf file...i know the shell command will
open
> > the
> > > program then the file but that wont work because the install directory
> for
> > > all the Acrobat programs is different...how can i open this file then