//通过Word接ISl得到当前活动文档pDoc
CComQIPtr<MSWORD::_Document> pDoc;
m_spApp->get_ActiveDocument(&pDoc);
//调用文档保护类型属性接口得到文档保护类型,并以此来判断在文档中
//是否添加新的签章。
CComQIPtr<MSWORD::Shapes> pShapes;
pDoc->get_Shapes(&pShapes);
CComQIPtr<MSWORD::Shape> pShape;
VARIANT type,anchor;
VARIANT m_left,m_top,m_width,m_hight;
VariantInit(&type);
VariantInit(&m_left);
VariantInit(&m_top);
VariantInit(&m_width);
VariantInit(&m_hight);
VariantInit(&anchor);
type.vt=VT_BSTR;
type.bstrVal =::SysAllocString(L"DEMOPIC.DemoPicCtrl.1");
m_left.vt=VT_I4; m_left.lVal = 30;
m_top.vt=VT_I4; m_top.lVal = 30;
m_width.vt=VT_I4; m_width.lVal = 50;
m_hight.vt=VT_I4; m_hight.lVal = 50;
anchor.vt=VT_I4; anchor.lVal = 30;
pShapes->AddOLEControl(&type,&m_left,&m_top,&m_width,&m_hight,&anchor,&pShape);
VariantClear(&type);
VariantClear(&m_left);
VariantClear(&m_top);
VariantClear(&m_width);
VariantClear(&m_hight);
VariantClear(&anchor);
方法2:
//通过Word接ISl得到当前活动文档pDoc
CComQIPtr<MSWORD::_Document> pDoc;
m_spApp->get_ActiveDocument(&pDoc);
//调用文档保护类型属性接口得到文档保护类型,并以此来判断在文档中
//是否添加新的签章。
CComQIPtr<MSWORD::InlieShapes> pShapes;
pDoc->get_InlineShapes(&pShapes);
CComQIPtr<MSWORD::InlineShape> pShape;
VARIANT type,rg;
VariantInit(&type);
VariantInit(&rg);
type.vt=VT_BSTR;
type.bstrVal =::SysAllocString(L"DEMOPIC.DemoPicCtrl.1");
rg.vt=VT_I4; rg.lVal = 30;
pShapes->AddOLEControl(&type,&rg,&pShape);
VariantClear(&type);
VariantClear(&rg);
请不吝赐教,万分感谢。