正在加载中...

信息详页

返回
怎么用VBA把WORD里的图片格式一次性改为“嵌入型”


来源:转载 浏览量:109 次 发布日期:2022-03-30

'* +++++++++++++++++++++++++++++
'* Created By SHOUROU@ExcelHome 2007-12-11 5:28:26
'仅测试于System: Windows NT Word: 11.0 Language: 2052
'№ 0281^The Code CopyIn [ThisDocument-ThisDocument]^'
'* -----------------------------
Option Explicit
Sub 图片版式转换()
    Dim oShape As Variant, shapeType As WdWrapType
    On Error Resume Next
    If MsgBox("Y将图片由嵌入式转为浮动式,N将图片由浮动式转为嵌入式", 68) = 6 Then
        shapeType = Val(InputBox(Prompt:="请输入图片版式:0=四周型,1=紧密型, " & vbLf & _
                                         "3=衬于文字下方,4=浮于文字上方", Default:=0))

        For Each oShape In ActiveDocument.InlineShapes

            oShape.Select

            Set oShape = oShape.ConvertToShape
            With oShape
                Select Case shapeType
                Case 0, 1
                    .WrapFormat.Type = shapeType
                Case 3
                    .WrapFormat.Type = 3
                    .ZOrder 5
                Case 4
                    .WrapFormat.Type = 3
                    .ZOrder 4
                Case Else
                    Exit Sub
                End Select
                .WrapFormat.AllowOverlap = False    '不允许重叠
            End With
        Next
    Else
        For Each oShape In ActiveDocument.Shapes
            oShape.ConvertToInlineShape
        Next
    End If
End Sub
'----------------------