作者:绿色风
分类:
时间:2022-08-17
浏览:171
楼主 xmyjk |
Q:将工作表中的批注中的图片导出指定的文件夹中存放
A:方法一:- Option Explicit
- Private Declare Function OpenClipboard Lib "User32" (ByVal hWnd As Long) As Long
- Private Declare Function CloseClipboard Lib "User32" () As Long
- Private Declare Function GetClipboardData Lib "User32" (ByVal uFormat As Long) As Long
- Public Declare Function OleCreatePictureIndirect Lib "olepro32.dll" (PicDesc As PicBmp, RefIID As GUID, ByVal fPictureOwnsHandle As Long, IPic As IPicture) As Long
- Private Type GUID
- Data1 As Long
- Data2 As Integer
- Data3 As Integer
- Data4(0 To 7) As Byte
- End Type
- Private Type PicBmp
- Size As Long
- Type As Long
- hBmp As Long
- hPal As Long
- Reserved As Long
- End Type
- Sub t()
- Dim rng As Range, flnm As String, Pic As PicBmp, IPic As IPicture, IID_IDispatch As GUID
- For Each rng In Sheet1.Cells.SpecialCells(xlCellTypeComments)
- If rng.Comment.Shape.Fill.Type = msoFillPicture Then
- flnm = ThisWorkbook.Path & "\" & rng.Value & ".bmp"
- With rng.Comment
- .Visible = True
- .Shape.CopyPicture 1, 2
- .Visible = False
- End With
- OpenClipboard 0
- With IID_IDispatch
- .Data1 = &H20400
- .Data4(0) = &HC0
- .Data4(7) = &H46
- End With
- With Pic
- .Size = Len(Pic)
- .Type = 1
- .hBmp = GetClipboardData(2)
- End With
- OleCreatePictureIndirect Pic, IID_IDispatch, 1, IPic
- stdole.SavePicture IPic, flnm
- CloseClipboard
- End If
- Next
- End Sub
方法二- Option Explicit
- Private Declare Function OpenClipboard Lib "User32" (ByVal hWnd As Long) As Long
- Private Declare Function CloseClipboard Lib "User32" () As Long
- Private Declare Function GetClipboardData Lib "User32" (ByVal uFormat As Long) As Long
- Private Declare Function CopyEnhMetaFileA Lib "Gdi32" (ByVal hemfSrc As Long, ByVal lpszFile As String) As Long
- Private Declare Function DeleteEnhMetaFile Lib "Gdi32" (ByVal hdc As Long) As Long
- Sub t()
- Dim rng As Range, flnm As String
- For Each rng In Sheet1.Cells.SpecialCells(xlCellTypeComments)
- If rng.Comment.Shape.Fill.Type = msoFillPicture Then
- flnm = ThisWorkbook.Path & "\" & rng.Value & ".JPG"
- With rng.Comment
- .Visible = True
- .Shape.CopyPicture xlScreen, xlPicture
- .Visible = False
- End With
- OpenClipboard 0
- DeleteEnhMetaFile CopyEnhMetaFileA(GetClipboardData(14), flnm)
- CloseClipboard
- End If
- Next
- End Sub
另存批注图片.rar 另存批注图片1.zip |
2楼 hylees |
学习 |
3楼 eliane_lei |
向楼主学习! |
4楼 老糊涂 |
|
免责声明
有感于原ExcelTip.Net留存知识的价值及部分知识具有的时间限定性因素,
经与ExcelTip.Net站长Apolloh商议并征得其同意,
现将原属ExcelTip.Net的知识帖采集资料于本站点进行展示,
供有需要的人士查询使用,也慰缅曾经的论坛时代。
所示各个帖子的原作者如对版权有异议,
可与本人沟通提出,或于本站点留言,我们会尽快处理。
在此,感谢ExcelTip.Net站长Apolloh的支持,感谢本站点所有人**绿色风(QQ:79664738)**的支持与奉献,特此鸣谢!
------本人网名**KevinChengCW(QQ:1210618015)**原ExcelTip.Net总版主之一