Home All Groups Group Topic Archive Search About

Open pdf file with button in VB 2005

Author
11 Jan 2006 8:55 PM
Jedi10180
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:

Show quoteHide quote
>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.

Author
11 Jan 2006 10:01 PM
Herfried K. Wagner [MVP]
"Jedi10180" <Jedi10***@discussions.microsoft.com> schrieb:
>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")
///

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
11 Jan 2006 11:31 PM
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

Show quoteHide quote
"Jedi10180" <Jedi10***@discussions.microsoft.com> wrote in message
news:010E5C93-B77A-45E4-A634-58425585E203@microsoft.com...
>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.
>
Author
11 Jan 2006 11:47 PM
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/
Author
14 Jan 2006 8:28 PM
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


Show quoteHide quote
"PJ on Development" <pjondevelopm***@gmail.com> wrote in message
news:1137023232.127420.316900@g49g2000cwa.googlegroups.com...
> 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/
>