我在 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
步骤 4:按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