Launching an Adobe PDF using the CreateObject command in FoxPro

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.

thispath="h:\cti\documents\"+clientno+ALLTRIM(thisfile)
loIE = Createobject("internetexplorer.application")
loIE.Visible = .T.
loIE.Navigate(thispath)

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?
HCPCJJ1Asked:
Who is Participating?
 
CaptainCyrilFounder, Software Engineer, Data ScientistCommented:
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)
CLEAR DLLS
0
 
Olaf DoschkeSoftware DeveloperCommented:
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.
0
 
HCPCJJ1Author Commented:
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.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.