ngduychien
VIP
Có nhưng lúc chúng ta cần xuất tất cả các ảnh trong một file excel ra lưu trữ để sử dụng, để làm được như thế chúng ta có thể tham khảo thủ tục sau.
Mã:
Sub SaveImages()
Dim shp As Shape, ImageName As String, Temp As Object, tArea As Object, x As Long
Application.ScreenUpdating = False
For Each Ws In ActiveWorkbook.Worksheets
For Each shp In Ws.Shapes
If shp.Type = msoPicture Then
x = x + 1
ImageName = "Pic" & x
shp.Select
Application.Selection.CopyPicture
Set Temp = Ws.ChartObjects.Add(0, 0, shp.Width, shp.Height)
Set tArea = Temp.Chart
Temp.Activate
With tArea
.ChartArea.Select
.Paste
.Export ("C:\Test\jpg\ok\" & ImageName & ".jpg")
End With
Temp.Delete
DoEvents
End If
Next shp
Next Ws
End Sub