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.
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
"It is much better to ask a shallow question than to wander in the depths of ignorance..."
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'
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
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.