Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to view a PDF file in a vb window 1

Status
Not open for further replies.

willy111

Programmer
Joined
May 3, 2004
Messages
2
Location
BE
I will show a pdf file (pages) in my program
(like a help file)
Can someone help me

Thanks (dank u)
 
Welcome to Tek-Tips. To get the best from the forum read faq222-2244.

To solve this question I would use the ShellExecute API. Declare it in a module (this is all on one line):

Code:
Public 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

Then I wrap it in a simple function:

Code:
Public Sub OpenThisDoc(formname As Long, FileName As String)
    On Error Resume Next
    Dim x As Long
    x = ShellExecute(formname, "Open", FileName, 0&, 0&, 3)
End Sub

Then call it as and when needed:

Code:
Call OpenThisDoc(0,"C:\hse1.pdf")

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

For tsunami relief donations

'If we're supposed to work in Hex, why have we only got A fingers?'

for steam enthusiasts
 
John,
Just out of pure curiosity...

Is there any particular reason you use Call, rather than just...
OpenThisDoc 0,"C:\hse1.pdf"

Or is it just a personal preference?

Don't get me wrong...
Both methods work the same...

I just always thought of Call as extra code, which just handles the Sub in the format of a Function, with the parenthesis "()" surrounding the parameters, and came through the legacy of Assembly for "Calling" sub procedures...

Visit My Site
PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
Cube,
No reason - I guess its the old gits way! [smile] Sadly I'm not consistent in its usage (shame on me)

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

For tsunami relief donations

'If we're supposed to work in Hex, why have we only got A fingers?'

for steam enthusiasts
 
Thanks johnwm, it works, in a seperate window. I can use this, thanks
Is it possible to show it in my own windows in my program? (and add possibilities such as zoom ?????)

Wilfried
 
You can add the PDF control (Acrobat Control for ActiveX) to your toolbox and place the control on your form. After that you can use the LoadFile method of the control to load a .pdf file in your control. The control provides all the features you need.

If the control is not listed in the components list, you can add it manually by browsing the file Reader\ActiveX\pdf.ocx in the Arocbat Reader folder.
 
So...

Is there a way to access the text in a pdf through VB?

That's the one thing I have yet to figure out how to do ;-)

Visit My Site
PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top