Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

MSWord FileOpen

Posted on 1997-02-28
4
258 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 170 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
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…

856 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