Resizing images when inserted by automation

D

David

Hi,

I am programming with Word automation to insert some images into word
document. I want to resize those images when they are inserted. I am using
C++ and automation interface to do it. Followed is the specification of
AddPicture function of InlineShapes object. I am wondering if I can specify
the "Range" variable to resize the images. If so, how should I initialize
"Range" variable? Thanks a lot!

HRESULT AddPicture(
[in] BSTR FileName,
[in, optional] VARIANT* LinkToFile,
[in, optional] VARIANT* SaveWithDocument,
[in, optional] VARIANT* Range,
[out, retval] InlineShape** prop);
 
J

Jean-Guy Marcil

David was telling us:
David nous racontait que :
Hi,

I am programming with Word automation to insert some images into word
document. I want to resize those images when they are inserted. I am
using C++ and automation interface to do it. Followed is the
specification of AddPicture function of InlineShapes object. I am
wondering if I can specify the "Range" variable to resize the images.
If so, how should I initialize "Range" variable? Thanks a lot!

HRESULT AddPicture(
[in] BSTR FileName,
[in, optional] VARIANT* LinkToFile,
[in, optional] VARIANT* SaveWithDocument,
[in, optional] VARIANT* Range,
[out, retval] InlineShape** prop);

Range refers to location in the document where you will add the inlineshape,
not to its size.
To resize the inline shape, try something like this. Adapt the VBA code to
C++, it is a VBA group after all! ;-)

Dim myInlineShp As InlineShape
Dim MyRge As Range

Set MyRge = Selection.Range
MyRge.Collapse

Set myInlineShp = ActiveDocument.InlineShapes. _
AddPicture("MyFile.bmp", False, True, MyRge)

With myInlineShp
'150% resizing
.ScaleHeight = 150
.ScaleWidth = 150
'Absolute resizing, can distort the picture...
.Width = InchesToPoints(1.5)
.Height = InchesToPoints(1.5)
End With
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top