Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word Automation - Insert picture and change size?

Status
Not open for further replies.

scriggs

IS-IT--Management
Jun 1, 2004
286
GB
I use Access to create a Word Document and populate with database fields. The latest addition has been to insert a picture from a file which I acheive with

Code:
        m_objWord.Selection.InlineShapes.AddPicture FileName:=recQ("ImageRef"), LinkToFile:=False, SaveWithDocument:=True

What I now need to do is adjust the size of the picture (say 2cm wide and then use auto proportions) - any suggestions on adapting the above command or using a new command?
 
The code you have should return a reference to a Shape object that represents the picture. Adjust the width of the Shape object (Shape.Width=x). This should give you what you want.
 
Thanks Presterman, just found that out myself!

As I couldnt find it easily, for anyone interested here is my code:

Code:
    Dim objPicture      As InlineShape              ' Customer Logo in Word document
    Dim intObjHeight       As Integer               'Integer to record current height
    Dim intObjWidth        As Integer               'Integer to record current width

m_objDoc.Bookmarks("Logo").Select
'Insert the picture into the Selection and name as objPicture
Set objPicture = m_objWord.Selection.InlineShapes.AddPicture(FileName:=recQ("ImageRef"), LinkToFile:=False, SaveWithDocument:=True)
'Re-size the image.
objWidth = objPicture.Width
objHeight = objPicture.Height
        
With objPicture
     .Height = CentimetersToPoints(objWidth / objHeight * 2)
     .Width = CentimetersToPoints(2)
End With
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top