我在 Word 2010 中製作了一個編號清單。我想要居中對齊所有圖像,但是當我嘗試居中對齊圖像時,上面的文字也會居中。
如何居中對齊清單中的圖像而不將上方和下方的文字居中。
答案1
好的,這就是你要做的:
- 右鍵單擊圖像並選擇“大小和位置...”
- 選擇“文字環繞”標籤
- 選擇“頂部和底部”
- 選擇“位置”標籤
- 在“水平”部分下,選擇“對齊”,然後選擇相對於“列”的“居中”
不幸的是,對多個圖像執行此操作是有問題的。格式畫家不起作用。此外,在嘗試選擇影像時,僅使用巨集錄製器會導致問題。
因此,創建一個 VBA 巨集並將其綁定到一個鍵似乎是實現超級高效的唯一方法。在這方面,這裡有兩個有用的帖子:
- https://groups.google.com/forum/?fromgroups=#!topic/microsoft.public.word.vba.general/j4ZaBiOYKDU
- https://stackoverflow.com/questions/9809475/insert-resize-and-relocate-image-using-a-microsoft-word-macro
從第一個參考文獻開始,我測試了以下 VBA 巨集。似乎工作正常!
Sub FormatMyPicture()
Dim myShape As Shape
If Selection.InlineShapes.Count > 0 Then
Set myShape = Selection.InlineShapes(1).ConvertToShape
ElseIf Selection.ShapeRange.Count > 0 Then
Set myShape = Selection.ShapeRange(1)
Else
MsgBox "Please select a picture first."
Exit Sub
End If
With myShape
.WrapFormat.Type = wdWrapTopBottom
.WrapFormat.DistanceTop = InchesToPoints(0.2)
.WrapFormat.DistanceBottom = InchesToPoints(0.2)
.RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
.Left = wdShapeCenter
End With
End Sub
答案2
若要在 MS Word 中將所有內嵌影像置中對齊:
步驟1:按Alt+F11開啟VBA編輯器
第2步: 去Insert
然後Module
步驟3:在 VBA 編輯器中輸入以下程式碼片段
Sub centerPictures()
Dim shpIn As InlineShape, shp As Shape
For Each shpIn In ActiveDocument.InlineShapes
shpIn.Select
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
Next shpIn
For Each shp In ActiveDocument.Shapes
shp.Select
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
Next shp
End Sub
第四步:按F5或按Run Sub
應用此更改
答案3
希望這能幫助特別的人
Sub rezize_center_newline()
Dim i As Long
Dim shpIn As InlineShape, shp As Shape
With ActiveDocument
For i = 1 To .InlineShapes.Count
With .InlineShapes(i)
.Height = InchesToPoints(4)
.Width = InchesToPoints(5.32)
.Range.InsertAfter Chr(13)
End With
Next i
For Each shpIn In ActiveDocument.InlineShapes
shpIn.Select
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
Next shpIn
For Each shp In ActiveDocument.Shapes
shp.Select
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
Next shp
End With
End Sub