MSWord FileOpen

Posted on 1997-02-28
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 ?
Question by:kso
  • 2

Expert Comment

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.



Author Comment

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

Author Comment

ID: 1299009
Adjusted points to 170

Accepted Solution

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

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


Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Multi Table MS Access Query 5 64
Help with ASP.NET C# CodeBehind for a Button and two text box controls 8 17
SQL to ElasticSearch Query 1 579
Problem to DocumentFormat 8 74
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
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.…

910 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now