Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

MSWord FileOpen

Posted on 1997-02-28
4
Medium Priority
?
267 Views
Last Modified: 2013-12-03
I have successfully used OLE Automation to open a file into MSWord from an MFC application. However, my problem is that if the MSWord get's started by the MFC application's COleDispatchDriver::CreateDispatch call then it also shuts down when my MFC application shuts down. How can I change this behaviour so that the MSWord would stay running even if the MFC application shuts down ?
0
Comment
Question by:kso
  • 2
4 Comments
 
LVL 1

Expert Comment

by:mbecker011597
ID: 1299007
I guess that COleDispatchDriver's destructor automatically closes the called application. Try to override the destructor that it does not close the application.

M.

0
 

Author Comment

by:kso
ID: 1299008
It's not possible to override a destructor.
Could I implement this without COleDispatchDriver by calling
AddRef() but not calling Release() ?
0
 

Author Comment

by:kso
ID: 1299009
Adjusted points to 170
0
 
LVL 1

Accepted Solution

by:
bhoward earned 510 total points
ID: 1299010
Launch Word before using the OLE Automation commands.  Use FindExecutable() and then WinExec().

HINSTANCE hinst;
char TheExe[ _MAX_PATH + 1];
hinst = (HINSTANCE)FindExecutable( "winword.exe", NULL, TheExe );
if (hinst > HINSTANCE_ERROR)
   WinExec( TheExe, SW_SHOW );
 

0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question