Open pdf file with button in VB 2005

G

Guest

I am making a CD for the non-profit organization I work for. The CD contains
all of the publications that we publish and will contain a GUI to access
them. When the user clicks on a publication button in the GUI, the pdf of the
publication needs to open in an Adobe Reader/Acrobat window. I can't figure
out how to make this work in VB.

I was told to try this:
You'd want to use ShellExecute, as shown on
http://vb.mvps.org/samples/hyperjmp...

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

Public Function OpenDoc(ByVal DocFile As String) As Long
' Actually uses the default verb if available, and "open" otherwise
OpenDoc = ShellExecute(0&, vbNullString, DocFile, vbNullString,
vbNullString, vbNormalFocus)
End Function

Pass the path/name of the desired PDF to this OpenDoc function.

I've tried that, but now my problem is I've been messing around with
ShellExecute for awhile and I'm having issues.
I don't think I'm passing the path/name of the PDF to the OpenDoc function
correctly. If I have a button named 'PDF', that calls the OpenDoc function
and passes the path/filename to it when it's clicked, what would the function
call look like?

Thanks for any help.
 
H

Herfried K. Wagner [MVP]

Jedi10180 said:
I am making a CD for the non-profit organization I work for. The CD
contains
all of the publications that we publish and will contain a GUI to access
them. When the user clicks on a publication button in the GUI, the pdf of
the
publication needs to open in an Adobe Reader/Acrobat window. I can't
figure
out how to make this work in VB.

\\\
System.Diagnostics.Process.Start("C:\sample.pdf")
///
 
P

Paul Bromley

In VB2003, embedding the Adobe Acrobat 7 Browser Document control in the
project works well for me, but I have not been able to find out the
licensing implications, of using this in a VB.NET project. The user needs to
install Acrobat Reader 7 on their machine. Can anyone confirm if this is an
acceptable use or not for the control??

Code:-

With AxPDF1
..Visible = True
..setShowToolbar((True))
..LoadFile("C:\Statement.pdf")
Cursor.Current = Cursors.Default
..Show()
..Select()
..SuspendLayout()
End With

Best wishes

Paul Bromley
 
P

PJ on Development

Paul,

The Acrobat Reader is a free tool, and as such can be freely
distributed.

Licensing implication would occur only if the software used
technologies from the Acrobat Generator (I forgot the proper name),
which I think it's not the case.

All in all, it's a good thing to ship the Acrobat Reader with the
application and install it on the user machine, warning the user of
such behavior (Can some one spell SONY? ;-)

It would be a good thing too to check if the user box has already the
Acrobat Reader installed (at least the bare minimum to read the docs)
before installing.

Regards,

PJ
http://pjondevelopment.50webs.com/
 
P

Paul Bromley

Thanks PJ

The reason I ask is that other PDF viewer controls seem to be so expensive.
Installing Reader 7 seems a small price to pay to use this control in your
applications.

Best wishes

Paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top