我使用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);
然而,在执行代码后,我发现文本总是放在图片之后,而不是在图片之前,为什么?
由于
答案 0 :(得分:1)
给出范围参数的描述(您提供的最后一个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.
我猜这与#34;自动放置"有关。尝试在文本之前插入占位符范围并将其指定为位置。