VBA代碼模塊,EXCEL圖片一鍵另存爲
Sub Opiona()
'On Error Resume Next '// 發生錯誤,自動執行下一句,就是忽略錯誤
Application.ScreenUpdating = False '//關閉屏幕刷新
Application.DisplayAlerts = False '//關閉系統提示
t = Timer '//開始時間
For Each shap In ActiveSheet.Shapes '//循環所有圖片
Set Rng = shap.TopLeftCell '//Range 對象,它代表位於指定對象左上角下方的單元格
'MsgBox shap.Name & "--" & Rng.Address
shap.Copy '//複製圖片
With ActiveSheet.ChartObjects.Add(0, 0, shap.Width, shap.Height).Chart '//建立一個新圖片
.Paste '//將複製的圖片放進去
.Export ThisWorkbook.Path & "/" & Range(Rng.Address).Value & ".JPG" '//導出爲圖片格式,如JPG,GIF
.Parent.Delete '//刪除自己建立的圖片
End With
Next
Application.ScreenUpdating = True '//恢復屏幕刷新
Application.DisplayAlerts = True '//恢復系統提示
MsgBox "一共用時:" & Format(Timer - t, "#0.0000") & " 秒" '//提示所用時間
End Sub