473,796 Members | 2,703 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.dl l" 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 10520
"Jedi10180" <Je*******@disc ussions.microso ft.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.Diagnost ics.Process.Sta rt("C:\sample.p df")
///

--
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
..setShowToolba r((True))
..LoadFile("C:\ Statement.pdf")
Cursor.Current = Cursors.Default
..Show()
..Select()
..SuspendLayout ()
End With

Best wishes

Paul Bromley

"Jedi10180" <Je*******@disc ussions.microso ft.com> wrote in message
news:01******** *************** ***********@mic rosoft.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.dl l" Alias
"ShellExecute A" (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,
vbNullStrin g, 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.goo glegroups.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
1508
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 code that would enable a form to open a specific pdf file? Details are below. -------------------- All of our purchase orders are saved back to pdf files. Each pdf has the
6
1276
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 it to complie ? What setting should I look into? Server Error in '/census' Application -------------------------------------------------------------------------------- Parser Error Description: An error occurred during the parsing of a...
15
4781
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 button will verify the information that has been entered and updates the data base if the data is correct. Update will throw an exception if the data is not validate based on some given rules. I also have a custom error handling page to show the...
2
3624
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 it builds ie first part of the path C:\Temp second part of the path kevin carter third part of the path Folder name and then the file name
6
3638
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 list of all of my webs, however if I attempt to open a site under and web other than localhost I receive the message: "Unable to open the Web 'http://localhost/anywebappname'. The Web 'http://localhost/anywebappname' does not exist" Obviously...
2
4252
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: ---------------------------------------------------------- Exception from HRESULT: 0xC004800A Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and...
13
39906
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 notepad so the user can see what was built. I cannot for the life of me figure out how to get the text file to open up in notepad on the screen. All the processes I have tried opens the file into the filestream again.
6
3109
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 highly appreciated
2
2449
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 databases in that server. Then after the user selects a database, I have another button that he/she click and I want to retrieve file groups from a specific table. At this point when he/she clicks on that button I get an error:
0
9685
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10239
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10190
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9057
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7555
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6796
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5579
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4122
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2928
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.