Consulting

Results 1 to 3 of 3

Thread: Macro to paste bunch of images at desired size in microsoft Word 2010.

  1. #1

    Macro to paste bunch of images at desired size in microsoft Word 2010.

    Hello guys,

    I want to make a macro that automatically resizes images (while preserving the height and weight ratio) when I paste them in Microsoft Word 2010.

    What I have now is this:

    Option Explicit

    Sub desiredimension()
    On Error Resume Next
    Dim oShp As Shape
    Dim iShp As InlineShape
    Dim ShpScale As Double
    With Selection
    For Each iShp In .InlineShapes
    With iShp
    If .Type = wdInlineShapePicture Or wdInlineShapeLinkedPicture Then

    .Height = 141.64
    End If
    End With
    Next iShp
    End With
    End Sub

    (but it doesnt do this automatically when I paste the images, I have to go and select them all and then apply the macro)

    Thanks a lot for the previous responses, that helped and helps me a lot at work and have a nice day.

  2. #2
    You can intercept the paste command and use it to paste and format e.g. as follows, but it will paste ALL images at the size you indicate.
    See also http://www.gmayor.com/photo_gallery_template.html
    Sub EditPaste()
    Dim iShp As InlineShape
    Dim oRng As Range
        Set oRng = Selection.Range
        oRng.Paste
        For Each iShp In oRng.InlineShapes
            With iShp
                If .Type = wdInlineShapePicture Or wdInlineShapeLinkedPicture Then
                    .LockAspectRatio = msoTrue
                    .Height = 141.64
                End If
            End With
        Next iShp
    lbl_Exit:
        Set oRng = Nothing
        Exit Sub
    End Sub
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

  3. #3
    That is exaclty what I wanted, perfect!
    Thanks a lot GMayor.

Posting Permissions

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