+ Reply to Thread
Results 1 to 2 of 2

Specify image size when loading into word bookmark

Hybrid View

ChrisMattock Specify image size when... 09-14-2007, 08:53 AM
Leith Ross Hello ChrisMattock, ... 09-14-2007, 03:01 PM
  1. #1
    Forum Contributor
    Join Date
    04-27-2006
    Location
    Cayman Islands
    Posts
    379

    Specify image size when loading into word bookmark

    Hey guys,

    I have an excel spreadsheet that populates a Word template, one of the bookmarks loads in an image....
    With appWD.ActiveDocument.Bookmarks("Logo")
            appWD.Selection.InlineShapes.AddPicture FileName:=ThisWorkbook.Path & "\templates\" & strLogo, LinkToFile:=False, SaveWithDocument:=True
    End With
    All works great, but is there a way to define the height of this image to save resizing the images manually?

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello ChrisMattock,

    Although this code was written for Excel, Word shares the StdPicture object. Add your inline object, and then use this macro to load the picture into it, and automatically resize it. Be sure strLogo includes the file extension.
    'Written: July 31, 2007
    'Author: Leith Ross
    'Summary; Change the size of shape to match the picture it will display
    
    Sub AutoSizeShapeToPicture(ByVal Shape_Name As String)
    
      Dim Pic As StdPicture
      
        FileName = ThisWorkbook.Path & "\templates\" & strLogo
        Set Pic = LoadPicture(FileName)
        
        ' Convert from himteric to inches
          With ActiveSheet.Shapes(Shape_Name)
            .Height = Pic.Height / 25.4
            .Width = Pic.Width / 25.4
            .Fill.UserPicture FileName
          End With
        
    End Sub
    Sincerely,
    Leith Ross

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1