Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does my picture appear before the text?

Tags:

c++

ms-word

I am using Visual C++ to automate Word, in the following code I try to insert text followed by a picture:

// 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);

However, after executing the code, I find the text is always put AFTER the picture, not BEFORE the picture, why?

Thanks

like image 776
alancc Avatar asked Dec 29 '17 06:12

alancc


1 Answers

Given the description of the range parameter (the last for which you provide 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.

I would guess this is something to do with "automatic placement". Try inserting a placeholder range before the text and specifying that as the location.

like image 76
SoronelHaetir Avatar answered Sep 24 '22 15:09

SoronelHaetir