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

Word test not working in exe 1

Status
Not open for further replies.

Bryan - Gendev

Programmer
Jan 9, 2011
408
AU
I have this code in my app

Code:
Set Defa To (mysystempath)
gotword =  FindApp('doc')	&& Test for Word
gotxls =  FindApp('xls')	&& Test for Excel

readpwini(inifile,'write','System','Word',Iif(gotword,'True','False'))
readpwini(inifile,'write','System','Excel',Iif(gotxls,'True','False'))

FindApp is Trevor Hancock's FindWord.

PROCEDURE Findapp
parameters ext
*~~~~~~~~~~~~~~~~~~~~~
* PROCEDURE FindWord
*
* AUTHOR: Trevor Hancock, , Microsoft Corporation
* CREATED : 08/22/00 11:50:32 AM


I get a True response in the development environment but a False when I run the compiled code as myapp.exe

Has anyone any ideas I can try.

I have used this in my app for 6 or 7 years from memory but have only just tested it again with my latest rebuild. The previous app release still works correctly.
WIN 7 64.

Thanks
GenDev
 
I found the source of FindWord here:
Wonder why that would return different values at design vs runtime.

Nevertheless it's not detecting 32bit vs 64bit. Finding an EXE installed and associated with .doc doesn't tell you it's 32bit. You may look for a "x86" in the full path to Word.EXE to see it's 32bit word, but like many apps the user can choose where to install, so that's not a failsafe test. Instead simply try to create a word instance:

Code:
Try
  loWord = CreateObject("Word.Application")
  Doevents Force
  llWordInstalled = (Vartype(loWord)="O")
Catch
  llWordInstalled = .F.
EndTry

Bye, Olaf.
 
Yes, detecting that Winword.exe is installed is intellectually satisfying, I suppose, but what you really want to know (usually) is whether or not you can create an instance.

Just be careful to release the instance at the end of your test! If your user runs your app 10 times in a day you don't want to leave them with 10 instances of Word doing nothing but hogging memory. ;-)
 
True, dan.

in this case I though of both a test and instanciation routine, so you would either return loWord or work with it right afterwards.

Bye, Olaf.
 
Thanks to all.

I now run the test given above and record the result so I've left it standalone.

I check the ini when I want them to use WORD

GenDev
 
With Release loWord as the last line of the findapp prg WINWORD is released but after I create a test document for the user it stays in the active processes.

Code:
loWord.ActiveDocument.close
Release loWord

What am I missing please?

GenDev
 
You only release your variable with Release loWord, that's not releasing word.

Do loWord.Quit() and then release the variable. The same goes for Excel.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top