//弄了2天,写了这么多代码。对不起自己工资啊。。。
void CPrintToWord::InsertControl(_DocumentPtr doc, CellPtr cell)
{
cell->Select();
CComVariant vsType("Forms.CheckBox.1");
InlineShapePtr shape =doc->ActiveWindow->Selection->InlineShapes->AddOLEControl(&vsType);
OLEFormatPtr spOleFormat = shape->OLEFormat;
IDispatchPtr pDisp =spOleFormat->GetObject();
CComDispatchDriver ComDisp(pDisp);
_variant_t AutoSize = VARIANT_TRUE;
ComDisp.PutPropertyByName( L"AutoSize", &AutoSize);//设为VARIANT_FALSE下面还不能赋值了。。
_variant_t vt;
vt.vt = VT_BSTR;
vt.bstrVal = ::SysAllocString(L"我是2010的阳光男孩");;
ComDisp.PutPropertyByName(L"Caption", &vt);
// //取值
// ComDisp.GetPropertyByName(L"Caption", &vt);
// USES_CONVERSION;
// LPTSTR lpstrMsg = W2T(vt.bstrVal);
}