|
楼主 |
发表于 2023-2-11 16:44
|
显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
您好,高手,我用您的代码,结果如下,不知道我代码有没有输错。
Sub ExportInlineShps()
Dim intIdx As Integer
Dim strPath As String
With ActiveDocument
If .InlineShapes.Count > 0 Then
strPath = .Path & "\"
For intIdx = 1 To .InlineShapes.Count
sSaveImg .InlineShapes(intIdx), strPath & intIdx & ".png"
Next
Else
MsgBox "没有图片"
End If
End With
End Sub
Sub sSaveImg(ByVal objShp As InlineShape, ByVal strFullPath As String)
Const TAG_S = "<pkg:binaryData>"
Const TAGE = "</pkg:binaryData>"
Dim objNode As Object 'MSXML2.IXMLDOMElement
Dim IngStart As Long, IngEnd As Long
Dim bytImage() As Byte
Dim strXML As String
Dim rngShp As Range
strXML = objShp.Range.WordOpenXML
1 ngStart = InStr(strXML, TAG_S)
If lngStart = 0 Then
MsgBox "没有图片数据"
Exit Sub
Else
lngStart = lngStart + Len(TAG_S)
lngEnd = InStr(IngStart, strXML, TAGE)
strXML = Mid$(strXML, IngStart, IngEnd - IngStart)
Set objNode = CreateObject("MSXML2.DOMDocument").createELement("b64")
objNode.DataType = "bin. base64"
objNode.Text = strXML
bytImage = objNode.nodeTypedValue
Open strFullPath For Binary As #1
Put #1, 1, bytImage
Close #1
Set objNode = Nothing
End If
End Sub
新建文件夹 (2).rar
(33.11 KB, 下载次数: 8)
|
|