Word VC++6 automation causing -2147023169 exception

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
 
D

Dave Hart

Chris

I compiled your code in an MFC Dialog App, and it works fine.
I am not seeing the exception.
I had to change your third #import statement to use the full path:
#import "C:\Program Files\Microsoft Office\Office\msword9.olb" rename(
"ExitWindows", "WordExitWindows" )

Dave Hart

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
 
C

Chris

Dave,

Thanks for making the effort. Unfortunately my machine has died, so
I'm in the middle of setting a new one up. I'll investigate further
when I'm in a position to.

Cheers,

Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top