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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Opeing PDF with VFP 1

Status
Not open for further replies.

mm0000

IS-IT--Management
May 19, 2002
295
IN
How can I open an adobe acrobat document for viewing from within Visual FoxPro by pressing a command button. The name path and name of the file is stored in a field in a table.

 
mm0000

You will find the Adobe Acrobat Control for ActiveX control somewhere on your system if you have the Acrobat Viewer installed.

To load a file, the syntax is:-

THISFORM.olePDF.LoadFile([path\filename.pdf])

HTH

Chris [pc2]
 
mm0000

You can also use a WIndows API call like what Rick Strahl did (thanks Mr. Strahl :)):


************************************************************************
*** Function: Opens a file in the application that it's
*** associated with.
*** Pass: lcFileName - Name of the file to open
*** lcWorkDir - Working directory
*** lcOperation - "Open" "Run" "Play" "Edit" etc...
*** Return: 2 - Bad Association (invalid URL)
*** 31 - No application association
*** 29 - Failure to load application
*** 30 - Application is busy***
*** Values over 32 indicate success
*** and return an instance handle for
*** the application started (the browser)
************************************************************************
FUNCTION ShellExec
LPARAMETERS lcFileName, lcWorkDir, lcOperation, pcParameters
LOCAL pp, lcParam
pp = pCount() && LAS v9b1w wgcs
if pp>3 && LAS v9b1w wgcs
lcParam = pcParameters && LAS v9b1w wgcs
else && LAS v9b1w wgcs
lcParam = ''
endif
lcWorkDir=IIF(type("lcWorkDir")="C",lcWorkDir,"")
lcOperation=IIF(type("lcOperation")="C",lcOperation,"Open")
DECLARE INTEGER ShellExecute ;
IN SHELL32.DLL ;
INTEGER nWinHandle,;
STRING cOperation,;
STRING cFileName,;
STRING cParameters,;
STRING cDirectory,;
INTEGER nShowWindow
RETURN ShellExecute(0,lcOperation,lcFilename,lcParam,lcWorkDir,1)
*ENDFUNC ShellExecute


This will work only if you have a PDF viewer installed.

torturedmind [trooper]

"It is much better to ask a shallow question than to wander in the depths of ignorance..."
 
Chris

Could not get it to work. I regiatered pdf.ocx and checkboxed adobe acrobat control in tools->options->controls but it gives an error 'unknown member olepdf'

Tortured mind

it works
 
mm0000

By default, I rename olecontrols to something more meaningful, in this case olePDF.

If you want to use the default name, the code is

THISFORM.olecontrol1.LoadFile([path\filename.pdf])


Using the Acrobat viewer is fine except you do not have the control over it as you would the ActiveX control.

Any pdfs opened by Acrobat Viewer become inaccessible to VFP for copying etc, whereas the ActiveX control only ever has a single pdf open.

Another word of warning - if you do decide to use the ActiveX control, should you then run the Acrobat Viewer at the same time, the pdf in the ActiveX control will simply dissapear! They can't run concurrently, even with different pdfs. HTH

Chris [pc2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top