SergeD
asked on
Launching Winword from C++
Hi,
I made a DLL supposed to launch a Word session based on a particular document.
Equivalent to: Start/Run/winword.exe F:\WPSS_Start.doc
I'm using the function _spawnlp as follow:
lReturnCode = _spawnlp( _P_WAIT, "winword.exe", "F:\WPSS_Start.doc" , NULL );
The result is: Word is effectively launched, but with a default docuemnt (document1.doc) instead of my personal document.
Any idea what I have done wrong?
Thanx
Serge
I made a DLL supposed to launch a Word session based on a particular document.
Equivalent to: Start/Run/winword.exe F:\WPSS_Start.doc
I'm using the function _spawnlp as follow:
lReturnCode = _spawnlp( _P_WAIT, "winword.exe", "F:\WPSS_Start.doc" , NULL );
The result is: Word is effectively launched, but with a default docuemnt (document1.doc) instead of my personal document.
Any idea what I have done wrong?
Thanx
Serge
ASKER
Hi,
I tried the double-backslash, and it still doesn't work (even if this filename works with the ShellExecute)
thanx for the suggestion for ShellExecute but it is not exactly what I'm looking for. If I open a doc file with ShellExecute, the default Word session is used. I would like to open a new Word session, to get the handle, and to close it later on with no changes on the user's session.
Any idea?
I tried the double-backslash, and it still doesn't work (even if this filename works with the ShellExecute)
thanx for the suggestion for ShellExecute but it is not exactly what I'm looking for. If I open a doc file with ShellExecute, the default Word session is used. I would like to open a new Word session, to get the handle, and to close it later on with no changes on the user's session.
Any idea?
Try using the short filename of the file.
Another option: use CreateProcess() WinExec()
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
It works but now I need to know how to get the path of the installed word.
Thanx anyway.
Serge
Thanx anyway.
Serge
lReturnCode = _spawnlp( _P_WAIT, "winword.exe", "F:\\WPSS_Start.doc" , NULL );
Anyway, it's always better to sue 'ShellExecute()', as it'll launch Word in the appropriate way:
ShellExecute ( NULL, "open", "f:\\WPSS_Start.doc", NULL, NULL, SW_SHOWNORMAL);