Consulting

Results 1 to 5 of 5

Thread: Formatting all pictures in word document

  1. #1

    Formatting all pictures in word document

    Hello,

    I have built macros for excel before but this is my first time attempting to build a macro with word.

    I have a document of approximately 800 images. I need all of these images to be formatted to be in front of text. This is what I tried and it did not work, I got an error message. It seems like this should be so simple but I cannot figure out what is wrong. Please help, thank you!

    Sub Pictures()
    '
    Dim Pic As InlineShape
    For Each Pic In ActiveDocument.InlineShapes
    Pic.Select
    Selection.ShapeRange.WrapFormat.Type = wdWrapFront
    Next
    End Sub

  2. #2
    VBAX Expert Dave's Avatar
    Joined
    Mar 2005
    Posts
    835
    Location
    What version of Office are U using and how did the pictures get there? Maybe it's that Converttoshape thing? Dave

  3. #3
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    Dave: The Office version isn't relevant.

    Angelfish: Since Pic is an InlineShape, it doesn't have a ShapeRange property. Try:
    Sub Pictures()
    Application.ScreenUpdating = False
    Dim Pic As InlineShape, Shp As Shape
    With ActiveDocument
      For Each Pic In .InlineShapes
        Pic.ConvertToShape
      Next
      For Each Shp In ActiveDocument.Shapes
        Shp.WrapFormat.Type = wdWrapFront
      Next
    End With
    Application.ScreenUpdating = True
    End Sub
    The above code will convert the pictures to in-front wrapping regardless of whether they're presently formatted as inlineshapes or anything else.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  4. #4
    VBAX Expert Dave's Avatar
    Joined
    Mar 2005
    Posts
    835
    Location
    Paul: Word for Office 13 apparently has difficulties with pics and pasting was the reason for the version inquiry. I think that I almost understand the convertoshape thing and purpose now. Thanks. Dave

  5. #5
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    I am not aware of any particular issues Word 2013 has with pics and, in any event, the VBA code for all Word versions is the same insofar as this thread is concerned.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

Posting Permissions

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