?
Solved

Open a pdf file in web browser unsing vb6

Posted on 2010-01-05
2
Medium Priority
?
347 Views
Last Modified: 2013-12-08
Hello,

I need to open a pdf file (c:\testpdf\exemple.pdf) thru the web browser, in VB6 programm.

Considering that various Acrobat reader versions should be installed on client computers (minimum version 6)

How can I do ?

Thanks in advance
0
Comment
Question by:lugos01
2 Comments
 
LVL 8

Accepted Solution

by:
Jon500 earned 2000 total points
ID: 26179231
Can you use ShellExecute to open a browser window with the location of the PDF as your Url?

In the code below use one of the constants in the declarations as 'the window state parameter.

Regards,
Jon500
Option Explicit

Const SW_SHOWMAXIMIZED = 3
Const SW_SHOWMINIMIZED = 2
Const SW_SHOWDEFAULT = 10
Const SW_SHOWMINNOACTIVE = 7
Const SW_SHOWNORMAL = 1

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
	

Private Function OpenLocation(URL As String, _ 
WindowState As Long) As Long

    Dim lHWnd As Long
    Dim lAns As Long

    lAns = ShellExecute(lHWnd, "open", URL, vbNullString, _ 
    vbNullString, WindowState)
   
    OpenLocation = lAns

    'ALTERNATIVE: if not interested in module handle or error
    'code change return value to boolean; then the above line
    'becomes:

    'OpenLocation = (lAns > 32)

End Function

Open in new window

0
 

Author Closing Comment

by:lugos01
ID: 31672850
Thanks a lot
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
Sometimes we receive PDF files that are in the wrong orientation. They may be sideways or even upside down. This most commonly happens with scanned or faxed documents. It is possible to rotate the view of these PDFs with the free Adobe Reader produc…
In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
Suggested Courses

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question