Article ID: 253501 - Last Review: May 14, 2007 - Revision: 8.2 How to pass a COleDispatchDriver as an argument for a method expecting a VARIANTThis article was previously published under Q253501 On This PageSUMMARY Some methods require that you pass a VARIANT that represents an Automation object. With MFC, these objects are typically handled by COleDispatchDriver-derived classes. To pass one of these to a method expecting a VARIANT, you can create a new VARIANT that has the vt member set to VT_DISPATCH and the pdispVal member set to the m_lpDispatch of the COleDispatchDriver class. MORE INFORMATION The following sample uses Microsoft Office Excel as the Automation
server. However, the technique that is illustrated can be used with other
Microsoft Office applications also. Sample codeExcel has several methods that require an object as a parameter. One method is the Worksheet::Add method. The following sample code demonstrates passing a COleDispatchDriver as a parameter to the Worksheet::Add method.REFERENCES
For more information about how to create an MFC Automation client for Microsoft Office applications, click the following article number to view the article in the Microsoft Knowledge Base:
178749
(http://support.microsoft.com/kb/178749/
)
How to create an automation project using MFC and a type library
For more information and for a sample for
developing Office solutions, visit the following Microsoft Web sites: http://support.microsoft.com/ofd
(http://support.microsoft.com/ofd)
http://support.microsoft.com/ph/2488 (http://support.microsoft.com/ph/2488) APPLIES TO
| Article Translations
|
Back to the top
