How to position an image in a Word doc using activex?

20 Ansichten (letzte 30 Tage)
James Boyle
James Boyle am 6 Sep. 2017
Kommentiert: fhz am 13 Feb. 2020
I can add an image to my document by using
selection.InlineShapes.AddPicture([pwd '/myimage.png'],0,1);
I can position it to an extent by spacing the cursor, but ultimately I need to be able to enable text wrapping for the image so that I can then move it anywhere within my document. I can't find any way to do this, but I'm sure it must be possible, and relatively simple. Many thanks if anybody knows how to achieve this. (Using windows)

Antworten (1)

fhz
fhz am 13 Feb. 2020
You can use the command
ActXWord.Selection.ParagraphFormat.Alignment = 1;
before
ActXWord.Selection.InlineShapes.AddPicture(figtoinsert,0,1);
The command
Selection.ParagraphFormat.Alignment = number
has the following options
% % options formats:
% % 0: Left-aligned
% % 1: Center-aligned
% % 2: Right-aligned
% % 3: Fully justified
% % 4: Paragraph characters are distributed to fill the entire
% % width of the paragraph
% % 5: Justified with a medium character compression ratio
% % 6: Does not exist.
% % 7: Justified with a high character compression ratio
% % 8: Justified with a low character compression ratio
% % 9: Justified according to Thai formatting Layout
  1 Kommentar
fhz
fhz am 13 Feb. 2020
It does not move figures after inserting them. It just more simple to define the alignment and other configurations before inserting the figures.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Use COM Objects in MATLAB finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by