Launching an Adobe PDF using the CreateObject command in FoxPro

Posted on 2011-04-19
Last Modified: 2012-05-11
I have some simple code on a form to view a PDF file.

The following code is on page 6 of a pageframe.  It is in the dblClick method of a text field on a grid.

loIE = Createobject("internetexplorer.application")
loIE.Visible = .T.

It works beautifully until you move to a different page in the pageframe and then come back.  Then, nothing happens when you double-click on the text field in the grid.  If you exit FoxPro and go back in, it works as before.  Any idea what I'm doing wrong?
Question by:HCPCJJ1
    LVL 27

    Accepted Solution

    What is the range of the variable loIE?

    Why not open the PDF in a webbrowser inside a VFP form?

    You can alternately call the PDF to open in default program.

    = ExecuteShell(cPDFFileName)

    FUNCTION ExecuteShell
    LPARAMETERS cFile, cOperation, cDefaultDirectory, cParameters
    LOCAL nHwnd, cParameters, cDefaultDirectory, nShowWindow
    DECLARE INTEGER ShellExecute IN shell32.dll AS ShellExecute;
          INTEGER nHwnd,;
          STRING @cOperation,;
          STRING @cFile,;
          STRING @cParameters,;
          STRING @cDefaultDirectory,;
          INTEGER nShowWindow
    nHwnd = 0
    cOperation = IIF(EMPTY(cOperation),'open',cOperation)
    cParameters = IIF(EMPTY(cParameters),NULL,cParameters)
    cDefaultDirectory = IIF(EMPTY(cDefaultDirectory),'',cDefaultDirectory)
    nShowWindow = 1
    = ShellExecute(nHwnd, @cOperation, @cFile, @cParameters, @cDefaultDirectory, nShowWindow)
    LVL 29

    Assisted Solution

    by:Olaf Doschke
    On Vista, it doesn't matter what happens with loIE after the internet Explorer exists. But in Windows7 that may differ. I know it does for Excel, Excel quits, if the foxpro variable get's out of scope, eg is redefined or released. A solution is to store loIE in some place that is not released, eg store it as an item of a collection you add to _screen.

    Cyril gives you other possible solutions: webbrowser control or ShellExecute.

    Bye, Olaf.

    Author Closing Comment

    Thank you for your responses.  Both were acceptable solutions, however, the problem turned out to be the fact that the grid control was mondified dynamically during the click of the page, and was taking out the Double-Click command once the page came into focus.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Training Course: Java/J2EE and SOA

    This course will cover both core and advanced Java concepts like Database connectivity, Threads, Exception Handling, Collections, JSP, Servlets, XMLHandling, and more. You'll also learn various Java frameworks like Hibernate and Spring.

    Suggested Solutions

    Title # Comments Views Activity
    Visual Fox Pro commands 15 16
    Report to PDF and TIF 33 1,394
    Move local views from one DBC to another 3 545
    Overlay data type 17 81
    Microsoft Visual FoxPro (short VFP) is a programming language with it’s own IDE and database, ranking somewhat between Access and VB.NET + SQL Server (Express). Product Description: (http://msd…
    Create and license users in Office 365 in bulk based on a CSV file. A step-by-step guide with PowerShell script examples.
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    779 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

    11 Experts available now in Live!

    Get 1:1 Help Now