C
Chris
Hi,
Hopefully someone can tell me what's going on here. I'm trying to
automate Word 2000 from VC++ 6 to do some printing, but I keep getting
"First-chance exception in DmhsmutTest.exe (KERNEL32.DLL):
0x800706BF:". 0x800706BF is -2147023169 aka RPC_S_CALL_FAILED_DNE.
I've cut down my code down to a dialog based app with my code in an
OnClick handler method. The app's InitInstance() calls CoInitialize(
NULL ) before the dialog is created, and CoUninitialize() afer the
DoModal returns. I'm #import-ing the following
#import "C:\\Program Files\\Microsoft Office\\Office\\MSO9.DLL"
#import "C:\\Program Files\\Common Files\\Microsoft
Shared\\VBA\\VBA6\\VBE6EXT.OLB"
#import "msword9.olb" rename( "ExitWindows", "WordExitWindows" )
and my handler code is
void CMyTestDlg::OnButton1()
{
using namespace Word;
_ApplicationPtr pWordApp = NULL;
HRESULT hres = pWordApp.CreateInstance( __uuidof( Application ) );
if( pWordApp )
{
pWordApp->Quit();
pWordApp.Release();
pWordApp = NULL;
}
}
The exception is thrown on the call to Release. Does this mean Quit
messes about with the reference counting? If I remove the call to Quit
then everything works fine, but the instance of winword.exe is still
in memory when the app exits? Any thoughts, as all the examples I can
find seem to be in VB.
Cheers,
Chris
Hopefully someone can tell me what's going on here. I'm trying to
automate Word 2000 from VC++ 6 to do some printing, but I keep getting
"First-chance exception in DmhsmutTest.exe (KERNEL32.DLL):
0x800706BF:". 0x800706BF is -2147023169 aka RPC_S_CALL_FAILED_DNE.
I've cut down my code down to a dialog based app with my code in an
OnClick handler method. The app's InitInstance() calls CoInitialize(
NULL ) before the dialog is created, and CoUninitialize() afer the
DoModal returns. I'm #import-ing the following
#import "C:\\Program Files\\Microsoft Office\\Office\\MSO9.DLL"
#import "C:\\Program Files\\Common Files\\Microsoft
Shared\\VBA\\VBA6\\VBE6EXT.OLB"
#import "msword9.olb" rename( "ExitWindows", "WordExitWindows" )
and my handler code is
void CMyTestDlg::OnButton1()
{
using namespace Word;
_ApplicationPtr pWordApp = NULL;
HRESULT hres = pWordApp.CreateInstance( __uuidof( Application ) );
if( pWordApp )
{
pWordApp->Quit();
pWordApp.Release();
pWordApp = NULL;
}
}
The exception is thrown on the call to Release. Does this mean Quit
messes about with the reference counting? If I remove the call to Quit
then everything works fine, but the instance of winword.exe is still
in memory when the app exits? Any thoughts, as all the examples I can
find seem to be in VB.
Cheers,
Chris