Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
developer
active.documents
automation
binary.file_format
clipboard.dde
com.add_ins
hosting.controls
internet_other
office.sdks
officedev
officedev.other
outlook.forms
outlook.vba
smarttags
vba
web.components
  
 
date: Mon, 1 Sep 2008 16:27:01 -0700,    group: microsoft.public.office.developer.com.add_ins        back       


Word Event returns no value   
I'm using ATL and c++ to develop an Add-in for Microsoft Word.  The problem 
that I'm having is that the parameters for the events that I'm trying to 
capture aren't being filled with data.  They're essentially null.  The 
problem is only happening with events that pass back more than one parameter.

The events that I am trapping are DocumentOpen, NewDocument, 
DocumentBeforePrint, and DocumentBeforeSave

DocumentOpen, and NewDocument event trapping work fine.

The dispinterface is ApplicationEvents2;  I've also tried using 
ApplicationEvents3, and ApplicationEvents4 with the same results.


/***********************************************
* IDL for DocumentOpen, NewDocument and DocumentBeforePrint
* and DocumentBeforeSave
************************************************/
[id(0x00000004), helpcontext(0x00061a84)]
void DocumentOpen([in] Document* Doc);

[id(0x00000009), helpcontext(0x00061a88)]
void NewDocument([in] Document* Doc);

[id(0x00000007), helpcontext(0x00061a86)]
void DocumentBeforePrint(
                [in] Document* Doc, 
                [in] VARIANT_BOOL* Cancel);

[id(0x00000008), helpcontext(0x00061a87)]
void DocumentBeforeSave(
                [in] Document* Doc, 
                [in] VARIANT_BOOL* SaveAsUI, 
                [in] VARIANT_BOOL* Cancel);


/**********************************************
* Here is the SINK_MAP
***********************************************/
BEGIN_SINK_MAP(MyAddin)
  SINK_ENTRY_INFO(1,__uuidof 
(Word::ApplicationEvents2),4,DocumentOpen,&DocumentOpenInfo)
	SINK_ENTRY_INFO(1,__uuidof(Word::ApplicationEvents2),9,NewDocument,&NewDocumentInfo)
	SINK_ENTRY_INFO(1,__uuidof(Word::ApplicationEvents2),7,DocumentBeforePrint,&DocumentBeforePrintInfo)
SINK_ENTRY_INFO(1,__uuidof(Word::ApplicationEvents2),8,DocumentBeforeSave,&DocumentBeforeSaveInfo)
END_SINK_MAP()

/******************************************************
* Here are the ATL_FUNC_INFO structures I've declared
*******************************************************/
_ATL_FUNC_INFO NewDocumentInfo = {CC_STDCALL,VT_EMPTY,1, 
{VT_DISPATCH|VT_BYREF}};
_ATL_FUNC_INFO DocumentBeforePrintInfo = {CC_STDCALL,VT_EMPTY,2, 
{VT_DISPATCH|VT_BYREF, VT_BOOL|VT_BYREF}};
_ATL_FUNC_INFO DocumentOpenInfo = {CC_STDCALL,VT_EMPTY,1, 
VT_DISPATCH|VT_BYREF}};
_ATL_FUNC_INFO DocumentBeforeSaveInfo = {CC_STDCALL,VT_EMPTY,3, 
{VT_DISPATCH|VT_BYREF, VT_BOOL|VT_BYREF, VT_BOOL|VT_BYREF}};

void __stdcall MyAddin::DocumentOpen(IDispatchPtr ptr)
{
    //Process DocumentOpen Event
}

void __stdcall MyAddin::NewDocument(IDispatchPtr ptr)
{  
   //Process NewDocument Event
}


void __stdcall MyAddin::DocumentBeforePrint(IDispatchPtr ptr, VARIANT_BOOL*  
pvtCancel )
{
 
   //The __vfPtr in ptr comes back as 0x00000000.  I don't know why
}

void __stdcall MyAddin::DocumentBeforeSave(IDispatchPtr ptr, VARIANT_BOOL*  
pSaveAsUI, VARIANT_BOOL* pCancel  )
{
      //The __vfPtr in ptr comes back as 0x00000000.  I don't know why
}
date: Mon, 1 Sep 2008 16:27:01 -0700   author:   Event Trapping using C++

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us