1. Welcome to Chandoo.org Forums. Short message for you

    Hi Guest,

    Thanks for joining Chandoo.org forums. We are here to make you awesome in Excel. Before you post your first question, please read this short introduction guide. When posting or responding to questions please remember our values at Chandoo.org are: Humility, Passion, Fun, Awesomeness, Simplicity, Sharing Remember that we have people here for whom English is not there first language and we need to allow for this in our dealings.

    Yours,
    Chandoo
  2. Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  3. When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

insert picture position in word using excel VBA

Discussion in 'VBA Macros' started by jk51, Apr 12, 2017.

  1. jk51

    jk51 Member

    Messages:
    50
    Hi

    I need help please on how to write coding correction part of the VBA excel program for inserting picture position in word 2010. I don't know how to write the absolute position with measurement syntax.

    Here is what I need:

    My picture size is H=12.75cm by W=19.32cm.
    In MS Word page layout setting:
    Horizontal
    I want it 'Absolute position' = 3.15cm to the right of Page
    Vertical
    I want it 'Absolute position' = 3.44cm below Page

    See my code below:

    Code (vb):
     Set aShape = wrdDoc.ActiveWindow.Selection.InlineShapes.AddPicture(Filename:=GraphImage, LinkToFile:=False, SaveWithDocument:=True).ConvertToShape
                 
                    With aShape
                            .Height = CentimetersToPoints(12.75)
                            .Width = CentimetersToPoints(19.32)
                         
                            .Left = CentimetersToPoints(3.15)
     
                            .RelativeHorizontalPosition = _
                                wdRelativeHorizontalPositionPage
                             
                            .Top = CentimetersToPoints(3.44)
                         
                            .RelativeVerticalPosition = _
                                wdRelativeVerticalPositionPage
                         
                            .Select
                    End With

    Thanks you.

    Best

    Mr Singh
  2. SirJB7

    SirJB7 Excel R┼Źnin

    Messages:
    8,883
    Hi, jk51!
    I don't understand why do you need Excel VBA code for modifying a Word file. And it's very difficult without both sample files, so consider uploading them.
    Regards!
  3. jk51

    jk51 Member

    Messages:
    50
    Hi SirJB7,

    I am inserting a picture per page and there are about 80 pictures (map in emf) image. The image are all of the same size. My picture size is H=12.75cm by W=19.32cm.
    I am trying to build a report generator using an excel database. I would like to insert pictures into word bookmarks.

    The program is working when inserting per page but not in the correct position. All I need to know to modify the part of the VBA coding on how to write the absolute position with measurement syntax.
    In MS Word page layout setting:
    Horizontal
    I want it 'Absolute position' = 3.15cm to the right of Page
    Vertical
    I want it 'Absolute position' = 3.44cm below Page

    It is a small procedure coding.
    I will be grateful if anyone know how to translate this on absolute position with my measurement in vba excel.

    Thanks.
    Mr Singh

Share This Page