473,394 Members | 1,889 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Open pdf file with button in VB 2005

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.

Jan 11 '06 #1
4 10497
"Jedi10180" <Je*******@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/>

Jan 11 '06 #2
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

"Jedi10180" <Je*******@discussions.microsoft.com> wrote in message
news:01**********************************@microsof t.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.

Jan 11 '06 #3
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/

Jan 11 '06 #4
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
"PJ on Development" <pj*************@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.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/

Jan 14 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Horness | last post by:
Hi All, We're in the process of re-writing the Intranet at work, and my javascript knowledge could be written on the back of a post card. ;-) Can any of you point me in the direction of some...
6
by: LU | last post by:
I open new project from web (Created from another computer). I add new web form to project, build/rebuild etc and I get Parse error below. (If I change codebehind = to src=) it works. How do I get...
15
by: Nathan | last post by:
I have an aspx page with a data grid, some textboxes, and an update button. This page also has one html input element with type=file (not inside the data grid and runat=server). The update...
2
by: kevcar40 | last post by:
Hi i am trying to open an excel file from access using a button the problem is the path and could change so i need to build the path to the file i am using textboxes to hold the information as...
6
by: Brad | last post by:
I have a win2003 server workstation with multiple webs, each web has it's own ip address. In VS2005, if I select to open an existing web site, select Local IIS, the dialog correctly displays a...
2
by: Seok Bee | last post by:
Dear Experts, In my web application, I am having a button to open a file located in the server. When I click on the button to view the file, I received the following error message:...
13
by: Chris Johnson | last post by:
I have what seems to be such a simple thing yet I cannot figure out how to do it. I am using a streamwriter to build a text file. At the end of the process I want to open that same text file in...
6
by: Moumen VB.NET 2003/2005 Developer | last post by:
How can I detect if a file sitting on a network drive is still open by another application? This application resides on another machine on the network? I am using VB.NET 2003 Your help is...
2
by: TG | last post by:
Hi! Once again I have hit a brick wall here. I have a combobox in which the user types the server name and then clicks on button 'CONNECT' to populate the next combobox which contains all the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.