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

Finding EXCEL 2

Status
Not open for further replies.

jjas

Programmer
Dec 30, 2002
2
US
Is there any way within a FoxPro environment to determine whether EXCEL is installed on a PC?

I would rather not use this code since it is not foolproof.

IF FILE('C:\Program Files\Microsoft Office\Office\EXCEL.EXE') = .T. .OR. ;
FILE('C:\Program Files\Microsoft Office\Office10\EXCEL.EXE') = .T.
Has_Excel = .T.
ELSE
Has_Excel = .F.
ENDIF
 
jjas

Try automating it and trap the error:
Code:
ON ERROR DO myExcelError
oEx = CREATEOBJECT("Excel.application")

PROCEDURE myExcelError
messagebox("There is no Excel installed on this system.")
ENDPROC

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Besides error trapping, I have just tested whether or not the wanted object is really an object.

** initialize object variable
oEx = CREATEOBJECT("Excel.application")

**** test validity of object
IF TYPE('oEx')="O"
ELSE
WAIT WINDOW "Problem using Excel on this PC."
ENDIF


==Carl
Carl Warner
VFUG Officer,
 
Carl

oEx = CREATEOBJECT("Excel.application")

According to my exprience, VFP will throw an error at the above line. If you don't trap it right away, it will look pretty ugly.
Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top