P
Philip Chan
When I add an ActiveX Control into word2000 with the following VBA code:
Sub demo()
Dim sp As Shape
Set sp =
ActiveDocument.Shapes.AddOLEControl("GABSignatureOffice.SignatureCtrl")
With sp.WrapFormat
.Type = wdWrapNone
.Side = wdWrapBoth
.AllowOverlap = True
End With
sp.ZOrder msoSendBehindText
sp.LockAspectRatio = msoTrue
Set sp = Nothing
End Sub
When the document was printed, the control is under the text as I expected.
Well, when I do the same work by a COM Addin with the following code:
CComPtr<Word::Shapes> pShapes;
hr = pDoc->get_Shapes(&pShapes);
ATLASSERT(SUCCEEDED(hr));
CComPtr<Word::Shape> pShape;
hr =
pShapes->AddOLEControl(&CComVariant(_T("GABSignatureOffice.SignatureCtrl")),
&vtMissing, &vtMissing, &vtMissing, &vtMissing, &vtMissing, &pShape);
ATLASSERT(SUCCEEDED(hr));
CComPtr<Word::WrapFormat> pWrapFormat;
hr = pShape->get_WrapFormat(&pWrapFormat);
ATLASSERT(SUCCEEDED(hr));
hr = pWrapFormat->put_Type(Word::wdWrapNone);
ATLASSERT(SUCCEEDED(hr));
hr = pWrapFormat->put_AllowOverlap(VARIANT_TRUE);
ATLASSERT(SUCCEEDED(hr));
hr = pWrapFormat->put_Side(Word::wdWrapBoth);
ATLASSERT(SUCCEEDED(hr));
hr = pShape->ZOrder(Office::msoSendBehindText);
ATLASSERT(SUCCEEDED(hr));
hr = pShape->put_LockAspectRatio(Office::msoTrue);
ATLASSERT(SUCCEEDED(hr));
the control was printed in front of text. What's the problem?
Sub demo()
Dim sp As Shape
Set sp =
ActiveDocument.Shapes.AddOLEControl("GABSignatureOffice.SignatureCtrl")
With sp.WrapFormat
.Type = wdWrapNone
.Side = wdWrapBoth
.AllowOverlap = True
End With
sp.ZOrder msoSendBehindText
sp.LockAspectRatio = msoTrue
Set sp = Nothing
End Sub
When the document was printed, the control is under the text as I expected.
Well, when I do the same work by a COM Addin with the following code:
CComPtr<Word::Shapes> pShapes;
hr = pDoc->get_Shapes(&pShapes);
ATLASSERT(SUCCEEDED(hr));
CComPtr<Word::Shape> pShape;
hr =
pShapes->AddOLEControl(&CComVariant(_T("GABSignatureOffice.SignatureCtrl")),
&vtMissing, &vtMissing, &vtMissing, &vtMissing, &vtMissing, &pShape);
ATLASSERT(SUCCEEDED(hr));
CComPtr<Word::WrapFormat> pWrapFormat;
hr = pShape->get_WrapFormat(&pWrapFormat);
ATLASSERT(SUCCEEDED(hr));
hr = pWrapFormat->put_Type(Word::wdWrapNone);
ATLASSERT(SUCCEEDED(hr));
hr = pWrapFormat->put_AllowOverlap(VARIANT_TRUE);
ATLASSERT(SUCCEEDED(hr));
hr = pWrapFormat->put_Side(Word::wdWrapBoth);
ATLASSERT(SUCCEEDED(hr));
hr = pShape->ZOrder(Office::msoSendBehindText);
ATLASSERT(SUCCEEDED(hr));
hr = pShape->put_LockAspectRatio(Office::msoTrue);
ATLASSERT(SUCCEEDED(hr));
the control was printed in front of text. What's the problem?