I dont know of any way you can use Class Wizard to add methods that have optional parameters. The way that I created the methods was to add the optional parameter in the .odl. The optional parameter needs to be of type VARIANT. When VB (or anyone else) calls the function without the optional parameter the VARIANT will contain VARIANT.vt = VT_ERROR VARIANT.scode = DISP_E_PARAMNOTFOUND..idl (may be slightly different syntax in .odl) [id(1030), helpstring("method Close")] HRESULT Close([in, optional] VARIANT bSaveChanges, [in, optional] VARIANT strFileName);.hSTDMETHOD(Close)(THIS_ /*[in, optional]*/ VARIANT varSaveChanges, /*[in, optional]*/ VARIANT varFileName);.cppSTDMETHODIMP CDoc::XDoc::Close ( VARIANT varSaveChanges ,VARIANT varFileName ) { .... }Check out KB articles Q154039 How To Pass Optional Arguments to MFC ActiveX Controls Q158451 How To Call Automation Methods with Variable Argument Lists
optional parameters. The way that I created the methods was to add the
optional parameter in the .odl. The optional parameter needs to be of type
VARIANT. When VB (or anyone else) calls the function without the optional
parameter the VARIANT will contain VARIANT.vt = VT_ERROR VARIANT.scode =
DISP_E_PARAMNOTFOUND..idl (may be slightly different syntax in .odl) [id(1030), helpstring("method Close")] HRESULT Close([in, optional] VARIANT
bSaveChanges, [in, optional] VARIANT strFileName);.hSTDMETHOD(Close)(THIS_ /*[in, optional]*/ VARIANT varSaveChanges, /*[in,
optional]*/ VARIANT varFileName);.cppSTDMETHODIMP CDoc::XDoc::Close
(
VARIANT varSaveChanges
,VARIANT varFileName
)
{
....
}Check out KB articles
Q154039 How To Pass Optional Arguments to MFC ActiveX Controls
Q158451 How To Call Automation Methods with Variable Argument Lists