VBA更改单词中所有图像的位置

时间:2014-10-29 12:45:28

标签: vba ms-word word-vba

我需要将所有图像设置为右侧,并将文本换行。

enter image description here

所以,它似乎很喜欢。

enter image description here

Sub convert()
    Dim shap As InlineShape, shapa As Shapes, sh As Shape
    For Each shap In ActiveDocument.InlineShapes
        shap.Select
        Selection.Fields.Unlink
        With Selection
            .WrapFormat.AllowOverlap = True
            .WrapFormat.Side = wdWrapBoth
            'Selection.Fields.Unlink
        End With
    Next shap
    For Each shap In ActiveDocument.InlineShapes
        shap.Select

        shap.ConvertToShape

    Next shap

    ActiveDocument.Shapes.SelectAll

    With Selection
        .ShapeRange.WrapFormat.Type = wdWrapTopBottom
        .ShapeRange.Top = wdShapeTop
        .ShapeRange.WrapFormat.Type = wdWrapTopBottom
        .ShapeRange.Left = wdShapeRight
    End With
End Sub

1 个答案:

答案 0 :(得分:0)

这样的事情可能有用。

Sub convert()
Dim shap As InlineShape, shapa As Shapes, sh As Shape
For Each shap In ActiveDocument.InlineShapes
    shap.Select
    Selection.Fields.Unlink
    Set sh = shap.ConvertToShape
    With sh
        .Left = wdShapeRight
        .WrapFormat.Type = wdWrapSquare
        .WrapFormat.AllowOverlap = True
        .WrapFormat.Side = wdWrapLeft
    End With
Next shap
End Sub

对于inlineshapes / shapes而言,一件可能很棘手的事情是你真的应该为形状设置一个新的变量,否则你会在对inlineshape类型的变量使用shape的属性时会出错。