Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2004

Tip: Looking for answers? Try searching our database.

Resizing images when inserted by automation

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
David - 24 Nov 2004 19:31 GMT
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);
Jean-Guy Marcil - 25 Nov 2004 03:48 GMT
David was telling us:
David nous racontait que :

> Hi,
>
[quoted text clipped - 11 lines]
>                [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
Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.