文件中大量圖片需統一設定(如置中、固定寬度、文字環繞方式),逐一手動設定極耗時。Word 可針對「嵌入式」與「環繞式」兩類圖片採用不同批次處理策略。
同理可批次設定:固定寬度、文字環繞樣式(需在「文字方塊」對話框「文字環繞」頁籤設定)、替代文字等。
「尋找取代」無法直接存取環繞式圖片的版面屬性。需撰寫 VBA 遍歷 `InlineShapes` (嵌入式) 或 `Shapes` (環繦式) 集合:
Sub FormatFloatingPictures()
Dim shp As Shape
For Each shp In ActiveDocument.Shapes
If shp.Type = msoPicture Or shp.Type = msoLinkedPicture Then
shp.WrapFormat.Type = wdWrapSquare ' 環繞類型:四周型
shp.Left = wdShapeCenter ' 水平置中
' shp.Width = CentimetersToPoints(10) ' 固定寬度 10 公分
End If
Next shp
End Sub
分類處理,嵌入式用尋找取代,環繞式用巨集,批次格式化不再頭痛。