|
代码修改完成。
每次导出100张图片后强制保存一次,然后继续,直到全部图片导出。
好处是,可以强行中断。因为每导出100次就会保存做备份。- Sub PicOutput()
- Redo:
- If Err.Number <> 0 Then Err.Clear
- n = ActiveSheet.Shapes.Count
- For i = 1 To n
- On Error GoTo Redo
- ActiveSheet.Shapes(i).Select
- ShpType = Selection.ShapeRange.Type
- If ShpType = msoPicture Then
- With Selection
- FileName = ThisWorkbook.Path & "" & .Name & ".gif"
- .Copy
- With ActiveSheet.ChartObjects.Add(0, 0, .Width + 2, .Height + 2).Chart
- .ChartArea.Border.LineStyle = 0
- .Paste
- .Export FileName, "gif"
- .Parent.Delete
- End With
- .Delete
- End With
- cnt = cnt + 1
- m = m + 1
- i = i - 1
- If m Mod 100 = 0 Then '这一句代码的保存间隔,可以自己设定调整为任意正整数。
- ActiveWorkbook.Save
- cnt = 0
- GoTo Redo
- End If
- End If
- Next
-
- If cnt = 0 Then
- MsgBox "Total " & m & " Pictures Output OK" & vbCr & _
- n & " Shapes Remain, Output Finished !"
- [a1].Select
- Else
- cnt = 0
- GoTo Redo
- End If
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|