Solved

MSWord FileOpen

Posted on 1997-02-28
4
261 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
[X]
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
  • 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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Run Program using VBScript 3 85
Dir function fails on mapped drives 28 154
Which Microsoft MSDN Package Is The One I need? 3 52
SSRS Deployment problem 5 126
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.  â€¦
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

752 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