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

How to detect if word,excel and outlook have been installed?

Status
Not open for further replies.

Johnweida

MIS
Apr 29, 2003
91
CN
experts,

Is there a way to detect if Microsoft Word,Excel and Outlook have been installed in the computer ? Thanks.

John Satellite
 
John,

The 'official' method is to check for certain Registry entries. I can give you more information on how to do that if you wish, but it is a little complicated, and relies on knowing the CLSIDs of the application (and version) in question.

A simpler approach is as follows:

lcOldError = ON("Error")
ON ERROR llFailed = .T.
loWord = CREATEOBJECT("word.application")
ON ERROR &lcOldError
IF llFailed
* Word not instantiated
ELSE
* Word instantiated OK
ENDIF

Or, in VFP 8.0, you can use the new-style error-trapping to achieve the same goal.

The problem is that this is not completely reliable, as there are other reasons for the CREATEOBJECT() to fail. Nevertheless, I have often adopted this approach, without too much trouble.

Mike


Mike Lewis
Edinburgh, Scotland
 
Mike,

I've tried your code and vfp8 told me that 'Variable llFailed is not found'. Please give me a further instruction. Thanks.

John Satellite
 
If there is no error, llFailed won't be initialized. Just add this line:

STORE .F. TO llFailed
Code:
lcOldError = ON("Error")
ON ERROR llFailed = .T.
loWord = CREATEOBJECT("word.application")
ON ERROR &lcOldError
IF llFailed 
  * Word not instantiated
ELSE
  * Word instantiated OK
ENDIF

-Dave S.-
[cheers]
Even more Fox stuff at:
 
Mike,

It has running well. Thank you very much !

John Satellite

 
Dear Mike,

Maybe this thread is not related with the topic.
I call Word in my application with the code below.

loWord = CREATEOBJECT("word.application")
loWord.visible = .T.

How to start Word with a new Doc file ?
Waiting for your help. Thanks.

John Satellite
 
John

loWord = CREATEOBJECT("word.application")
loDocumnent = loWord.documents.add()
loWord.Visible = .t.



Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Mike,

Your code is very good. You are great ! Thank you very much.

John Satellite
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top