Click to See Complete Forum and Search --> : Opening word docs using ShellExecuteEx
derdeniska
June 15th, 2005, 06:44 AM
Hi.
I've got the following problem:
I've developed an application that opens doc files using ShellExecuteEx.
I pass path to file and file name to ShellExecuteEx and doc is opened with the currently installed Word. Now the problem is that it doesn't seem to work on all PCs. It works fine on word2000 but failes on word 2002. The funny thing is that word document OPENS, but ShellExecuteEx returns a null as a handle to the process. What shall I do?
Thankfull in advance, Denis.
SuperKoko
June 15th, 2005, 06:52 AM
I am not sure, but i have probably an explanation.
Word 2002 define a context menu shell extension to optimize the launching (to avoid launching of two different Word.exe processes for example) or to add document-dependant verbs for example.
In that case you can't get the hProcess, because shell extensions are inprocess COM servers, loaded in explorer.exe process.
I am not sure, but the use of DDE for the verb definition in the registry base could be also a source of impossibility to get the hProcess.
To see if a verb is added in the registry base, you should use regedit and search the open verb of .doc files.
derdeniska
June 15th, 2005, 07:01 AM
Well, I still need to know when file is closed.
Is there any other API to trace opened files, or to trace file opening/closure?
NoHero
June 15th, 2005, 07:49 AM
Modern programs use DDE server to check for incoming shell extensions events for example when the user opens a file. Thus no program is executed but a proper event is sent over DDE to the currently running instance of winword.exe. And all the stuff the instance does is internally. That's why ShellExecuteEx() returns NULL. Since the Microsoft Word executeable is named winword.exe (in every version) you can try calling it directly and pass the document via command line parameters.
derdeniska
June 16th, 2005, 01:25 AM
Tried that, same result.
SuperKoko
June 16th, 2005, 01:28 PM
I suggest that you use the OLE interface of Word.
I have never used it, but i suggest that you read MSDN documentation about the Word.Application (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_wrcore/html/wrgrfapplicationobject.asp) object.
I hope that you will find the set of functions that can solve your problem in the many interfaces of Word.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.