Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Feb 2015
    Thanked 0 Times in 0 Posts

    Word 2010 for positioning image on left bottom of the page.

    I have more or less successfuly coded a macro to generate a Shape object, then insert an image into that Shape. Then redimension the shape to fit the image and finally place the redimensioned Shape in the top center of the page without having to enter any hardcoded coordinates. The code is as follows:

    Sub Macro()
    Dim shpCanvas As Shape
    Dim shpImagen As Shape
    Dim porcen As Double
    ' Shape generation with a default size enough to fit any suitable image.
       Set shpCanvas = ActiveDocument.Shapes.AddCanvas(Left:=0, Top:=0, Width:=600, Height:=600)
    ' Addition of an example image that can be altered outside word at any time (size included)
       shpCanvas.CanvasItems.AddPicture _
            FileName:="C:\ExampleImageFile.JPG", _
            LinkToFile:=False, SaveWithDocument:=True, Left:=0, Top:=0
    ' Redimension of the Shape object to fit the loaded image size    
       Set shpImagen = shpCanvas.CanvasItems(1)
       porcen = shpImagen.Width
       porcen = porcen / shpCanvas.Width
       shpCanvas.CanvasCropRight porcen
       porcen = shpImagen.Height
       porcen = porcen / shpCanvas.Height
       shpCanvas.CanvasCropBottom porcen
    ' Positioning the generated Shape on the top center of the page
       shpCanvas.Left = wdShapeCenter
    End Sub
    However i'm having no luck to place an image in a similar way on the bottom left part of the page.

    I have tried adding "shpCanvas.Top = wdShapeBottom" but as expected it doesn't work.
    The only idea that comes to my mind would be to find the Height of the page and do the calculations myself to position the image but i don't have a clue about finding the Height of the page. Or maybe there's an easier and safer way to do it.

    I would be very grateful if someone could tell me how position automatically an image on the left bottom corner of the page or in a worst case scenario how to find the Height of the page to do the calculations myself..

    Thank you.

  2. #2
    Super Moderator
    Join Date
    Jan 2001
    Melbourne, Victoria, Australia
    Thanked 259 Times in 239 Posts
    There is probably a cleaner way to do this but if you added the following two lines to the end of that macro then the image would be at the bottom of the page
    shpCanvas.RelativeVerticalPosition = wdRelativeVerticalPositionPage
    shpCanvas.Top = shpCanvas.Anchor.Sections.PageSetup.PageHeight - shpImagen.Height
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  3. #3
    New Lounger
    Join Date
    Feb 2015
    Thanked 0 Times in 0 Posts
    Thenk you for the reply, that will work good enough.

Posting Permissions

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