2014-10-29 80 views
0

我需要將所有圖像設置在右側幷包裝文本。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 

回答

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 /形狀是,你真的應該爲形狀的新變量,否則你會在一個變量的類型是inlineshape的使用形狀的屬性時出現錯誤。