Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP & Adobe Reader
Message
 
To
29/10/2004 11:14:54
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows 2000 SP4
Network:
Windows 2000 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
00955811
Message ID:
00955817
Views:
27
Hi Dean,
Here is code I picked up on the UT some time ago. Basically it will run the registered program dependant on the file type. I found it works perfectly. Just make sure Adobe Acrobat Reader is installed correctly.


********************************************************************
* Description.......: RunDoc - opens any document
* Calling Samples...:
* Parameter List....: tcDocument
* Created by........: Hilmar Zonneveld November 8, 2001 10:43
* Modified by.......:
********************************************************************
* Sample use:
* MyFile = "Document.pdf"
* RunDoc(MyFile)

FUNCTION RunDoc(tcDocument)
if vartype(m.tcDocument)<>"C" or !file(m.tcDocument)
return .f. && Invalid parameter
endif
local lnResult

DECLARE INTEGER ShellExecute ;
IN SHELL32.dll ;
INTEGER nWinHandle, ;
STRING cOperation, ;
STRING cFileName, ;
STRING cParameters, ;
STRING cDirectory, ;
INTEGER nShowWindow

**retreive the main VFP window handle (this handle is used by ShellExecute)

DECLARE INTEGER FindWindow ;
IN WIN32API ;
STRING cNull, ;
STRING cWinName

lnResult=ShellExecute(FindWindow( 0, _SCREEN.caption), "Open", tcDocument, "", sys(2023)+'\', 1)

**Error messages if the return value is < 32
IF m.lnResult < 32
DO CASE
CASE m.lnResult=2
Wait wind "Invalid association or URL."
CASE m.lnResult=31
Wait wind "No association."
CASE m.lnResult=29
Wait wind "Can't start application."
CASE m.lnResult=30
Wait wind "Application is already open."
ENDCASE
ENDIF
return m.lnResult>=32
ENDFUNC
Kevin Delaney
Financial Systems Manager
CPL Solutions Ltd

83 Merrion Square, Dublin 2, Ireland.
e: kevin.delaney@cpl.ie w: www.cpl.ie
p: +353 1 482-5368
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform