用宏批量调整word中图片版式、大小、方向
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
Sub 图片对齐() (1)
Sub 图片大小() (1)
Sub 浮于文字上方() ................................................................................................... 错误!未定义书签。Sub 浮于文字上方() . (4)
Sub 连续() (4)
Sub 版式转换() (4)
Sub 图片方向() (5)
Sub 图片对齐()
Application.ScreenUpdating = False '关闭屏幕更新
Dim n
On Error Resume Next
For n = 1 To ActiveDocument.Shapes.Count
ActiveDocument.Shapes(n).Select
Selection.ShapeRange.RelativeHorizontalPosition = _
wdRelativeHorizontalPositionMargin
Selection.ShapeRange.RelativeVerticalPosition = _
wdRelativeVerticalPositionMargin
Selection.ShapeRange.Left = wdShapeRight
Selection.ShapeRange.Top = wdShapeBottom
Selection.ShapeRange.LockAnchor = False
youtInCell = True
Selection.ShapeRange.WrapFormat.AllowOverlap = False
Selection.ShapeRange.WrapFormat.Side = wdWrapBoth
Next
Application.ScreenUpdating = True '恢复屏幕更新
End Sub
Sub 图片大小()
On Error Resume Next
Dim mywidth
Dim myheight
Application.ScreenUpdating = False '关闭屏幕更新
mywidth = Val(InputBox(Prompt:="单位为厘米(cm);如果输入为0,则图片保持原始纵横比,宽度根据输入的高度数值自动调整;", Title:="请输入图片宽度", Default:="0")) * 28.35
myheight = Val(InputBox(Prompt:="单位为厘米(cm);如果输入为0,则图片保持原始纵横比,高度根据输入的宽度数值自动调整;", Title:="请输入图片高度", Default:="0")) * 28.35
'------------------------------------------------------------------
'调整嵌入式图形
Dim pic As InlineShape
For Each pic In ActiveDocument.InlineShapes
If mywidth = "0" Then
pic.Height = myheight
pic.ScaleWidth = pic.ScaleHeight
ElseIf myheight = "0" Then
pic.Width = mywidth
pic.ScaleHeight = pic.ScaleWidth
Else
pic.Width = mywidth
pic.Height = myheight
End If
Next
'调整浮动式图形
Dim tu As Shape
For Each tu In ActiveDocument.Shapes
If mywidth = "0" Then
tu.Height = myheight
ElseIf myheight = "0" Then
tu.Width = mywidth
Else
tu.LockAspectRatio = msoFalse
tu.Width = mywidth
tu.Height = myheight
End If
Next
Application.ScreenUpdating = True '恢复屏幕更新
End Sub
Sub 浮于文字上方()
Dim oShape As Variant, tu As Shape, i
Application.ScreenUpdating = False '关闭屏幕更新
On Error Resume Next
'调整嵌入图形为浮于文字上方,并旋转90度
For Each oShape In ActiveDocument.InlineShapes
Set oShape = oShape.ConvertToShape
ActiveDocument.InlineShapes(i).Select
With oShape
.WrapFormat.Type = 3' (去除.Zorder行.WrapFormat.Type = shapeType四周形.WrapFormat.Type = wdWrapTight紧密形改为.ConvertToInlineShape嵌入形)
.ZOrder 4 '4浮于文字上方5衬于下方
.Rotation = -90#
End With
Next
'调整其它图形为浮于文字上方,并旋转90度
For Each tu In ActiveDocument.Shapes
ActiveDocument.Shapes(i).Select
With tu
.WrapFormat.Type = 3' (去除.Zorder行.WrapFormat.Type = shapeType四周形.WrapFormat.Type = wdWrapTight紧密形改为.ConvertToInlineShape嵌入形)
.ZOrder 4 '4浮于文字上方5衬于下方
.Rotation = -90#
End With
Next