Results 1 to 2 of 2
  1. #1
    New Lounger
    Join Date
    Dec 2001
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Formatting a Picture in Word (VBA / Word)

    I am trying to programically format a picture in Word with no success. Here are the steps I am taking;

    First I insert a *.tif into a Word Document. Then select 'Format | Picture | Layout' select 'Tight and click Left'. This works fine when done manually, but when I try to record these steps, the 'Wrapping Style' Options are greyed out.

    Next when I tried the following code on the unformatted *.tif, Word generages the error "4198", Command Failed;

    Selection.ShapeRange.WrapFormat.Type = wdWrapTight
    Selection.ShapeRange.Left = wdShapeLeft
    Selection.ShapeRange.Top = InchesToPoints(0)

    Any Ideas on how this can be done in a Macro?

    Thank you
    Roland Thomas

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Formatting a Picture in Word (VBA / Word)

    The instruction
    Selection.ShapeRange.Left = wdShapeLeft
    seems strange to me. You set the left position of the shape to a (non-existing?) Word VBA constant. If you want text to wrap to the left of the shape, you need to use
    Selection.ShapeRange.WrapFormat.Side = wdWrapLeft

    Here is what I got when recording Format/Picture. The only thing I changed was to use With Selection.ShapeRange ... End With in order to avoid endless repetition. (Note: my system is set to metric, so I get CentimetersToPoints instead of InchesToPoints.)

    With Selection.ShapeRange
    .Fill.Visible = msoFalse
    .Fill.Transparency = 0#
    .Line.Weight = 0.75
    .Line.DashStyle = msoLineSolid
    .Line.Style = msoLineSingle
    .Line.Transparency = 0#
    .Line.Visible = msoFalse
    .LockAspectRatio = msoTrue
    .Height = 118.2
    .Width = 453.55
    .PictureFormat.Brightness = 0.5
    .PictureFormat.Contrast = 0.5
    .PictureFormat.ColorType = msoPictureAutomatic
    .PictureFormat.CropLeft = 0#
    .PictureFormat.CropRight = 0#
    .PictureFormat.CropTop = 0#
    .PictureFormat.CropBottom = 0#
    .RelativeHorizontalPosition = _
    wdRelativeHorizontalPositionColumn
    .RelativeVerticalPosition = _
    wdRelativeVerticalPositionParagraph
    .Left = CentimetersToPoints(3)
    .Top = CentimetersToPoints(0)
    .LockAnchor = False
    .WrapFormat.Type = wdWrapTight
    .WrapFormat.Side = wdWrapLeft
    .WrapFormat.DistanceTop = CentimetersToPoints(0)
    .WrapFormat.DistanceBottom = CentimetersToPoints(0)
    .WrapFormat.DistanceLeft = CentimetersToPoints(0.32)
    .WrapFormat.DistanceRight = CentimetersToPoints(0.32)
    End With

Posting Permissions

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