Xuất tất cả Image trong Worksheetd ra file bằng VBA

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
 
Thêm 1 cách khác để mọi người tham khảo.
Có thể lưu file excell chứa ảnh sang dạng Web page
Bạn cần đăng nhập để thấy đính kèm

Lúc này nó sẽ tự động tạo ra 1 forder chứa các ảnh trong file excell
 
Sửa lần cuối:
Top