Open a pdf file in web browser unsing vb6

Posted on 2010-01-05
Last Modified: 2013-12-08

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
Question by:lugos01
    LVL 8

    Accepted Solution

    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.

    Option Explicit
    Const SW_SHOWDEFAULT = 10
    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
        'OpenLocation = (lAns > 32)
    End Function

    Open in new window


    Author Closing Comment

    Thanks a lot

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    This article focuses on how to remove password security from multiple PDF files by Adobe Acrobat program. Sometimes it is essential to access the stored data items and to print, edit as well as copy content from Portable Document Format files in abs…
    Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    754 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

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now