Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am trying to get at the _Document object and the Cancel instruction for MS Word in the functions DocumentBeforeSave and DocumentBeforeClose.

I have the listener all hooked up and these events are being caught in the case statement ...

  case 0x00000006:  // DocumentBeforeClose([in] Document* Doc, [in] VARIANT_BOOL* Cancel);
     OutputDebugString( "DocumentBeforeClose\n");
     if(pDispParams->cArgs !=2)
        return E_INVALIDARG;
     else
     {
            VARIANT_BOOL* bValue = NULL;
            _Document* docVal;

            //First one as the doc
            if(pDispParams->rgvarg[1].vt & VT_BYREF) 
                docVal = ((_Document*)*(pDispParams->rgvarg[1].ppunkVal));
            else
                docVal = ((_Document*)(pDispParams->rgvarg[1].punkVal));

            //Second one the cancel
            bValue = pDispParams->rgvarg[0].pboolVal;

            DocumentBeforeClose(docVal,bValue);
     }
     break;

and it passes control to the function:

STDMETHODIMP CAppEventListener::DocumentBeforeClose( _Document* pDoc, VARIANT_BOOL* Cancel ) {

return S_OK; }

Problem is, if I want to get at the properties and methods of pDoc, it throws an exception. Also don't know how to cancel the DocumentBeforeClose dependent on certain conditions. Am I on the wrong track?

Bob

share|improve this question

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.