我使用Visual C++自动化Word,在下面的代码中我尝试插入文本后跟图片:
// OLEParagraphs is an object of COLEParagraphs
COLEParagraph LastParagraph = OLEParagraphs.get_Last();
COLERange LastParagraphRange = LastParagraph.get_Range();
COLEInlineShapes InlineShapes = LastParagraph.get_InlineShapes();
LastParagraphRange.put_Text(_T(“See picture below:”));
InlineShapes.AddPicture(strPicFileName, COleVariant(0l), COleVariant(1l), DOCX_VARIANT_OPTIONAL);
Run Code Online (Sandbox Code Playgroud)
但是,在执行完代码后,我发现文本总是放在图片之后,而不是在图片之前,为什么?
谢谢
给出范围参数的描述(您为其提供 DOCX_VARIANT_OPTIONAL 的最后一个参数):
Optional Object. The location where the picture will be placed in the text. If the range isn't collapsed, the picture replaces the range; otherwise, the picture is inserted. If this argument is omitted, the picture is placed automatically.
Run Code Online (Sandbox Code Playgroud)
我猜这与“自动放置”有关。尝试在文本前插入占位符范围并将其指定为位置。
| 归档时间: |
|
| 查看次数: |
231 次 |
| 最近记录: |