|
本帖最后由 duquancai 于 2017-2-20 23:56 编辑
- Private Sub CommandButton1_Click()
- Dim imagtream As Object, fol As Object, doc As Document, p As InlineShape
- Dim pa$, f$, pf$, pu$
- Set fol = CreateObject("Shell.Application").BrowseForFolder(0, "GetFolder", 0)
- If Not fol Is Nothing Then pa$ = fol.Items.Item.Path Else MsgBox "请选目标文件夹": Exit Sub
- Set imagtream = CreateObject("ADODB.Stream")
- f = Dir(pa & "\*.doc*"): pu = ThisDocument.Path & ""
- Do While f <> ""
- If ThisDocument.Name <> f Then
- Set doc = Documents.Open(pa & "" & f, Visible:=False)
- pf = Left(f, InStrRev(f, ".") - 1)
- For Each p In doc.InlineShapes
- i = i + 1
- With imagtream
- .Type = 1: .Open
- .Write p.Range.EnhMetaFileBits
- .SaveToFile pu & pf & i & ".jpg", 2: .Close
- End With
- Next
- doc.Close 0
- End If
- f = Dir
- Loop
- MsgBox "导出完毕!图片保存于本文档所在文件夹内"
- End Sub
复制代码 |
|