2,503
社区成员




各位老大
大家好。
我想把EXCEL单元格里的图片批量导出来,并且以人名来命名,写完的代码哪里有问题,拜托大家指导一下。
感谢。
Sub Rename()
Application.ScreenUpdating = False
On Error Resume Next
MkDir ThisWorkbook.Path & "\pho"
For Each pic In ActiveSheet.Shapes
If pic.Type = msoPicture Then
rn = pic.TopLeftCell.Offset(0, -1).Value
pic.Copy
With ActiveSheet.ChartObjects.Add(0, 0, pic.Width, pic.Height).Chart
.Parent.Select
.Paste
.Export ThisWorkbook.Path & "\pho" & rn & ".jpg"
.Parent.Delete
End With
End If
Next
MsgBox "导出图片完成!"
Application.ScreenUpdating = True
End Sub
Sub Rename()
Application.ScreenUpdating = False
On Error GoTo ErrorHandler
MkDir ThisWorkbook.Path & "\pho\"
For Each pic In ActiveSheet.Shapes
If pic.Type = msoPicture Then
rn = pic.TopLeftCell.Offset(0, -1).Value
pic.Copy
With ActiveSheet.ChartObjects.Add(0, 0, pic.Width, pic.Height).Chart
.Parent.Select
.Paste
.Export ThisWorkbook.Path & "\pho\" & rn & ".jpg"
.Parent.Delete
End With
End If
Next
MsgBox "导出图片完成!"
Application.ScreenUpdating = True
Exit Sub
ErrorHandler:
MsgBox "发生错误: " & Err.Description
Application.ScreenUpdating = True
End Sub
1