VBA运行时错误1004代码..方法saveas作用于对象_workbook时失败(2010版excel)

2024年12月04日 23:32
有1个网友回答
网友(1):

Sub savetofile()
Application.ScreenUpdating = False

on error resume next '忽略错误,继续执行

Dim folder As String
folder = ThisWorkbook.Path & "\班级成绩表"
If Len(Dir(folder, vbDirectory)) = 0 Then MkDir folder
Dim sht As Worksheet

For Each sht In thisworkbook.Worksheets
if sht.name<>"成绩表" then '判断表名
sht.Copy
ActiveWorkbook.SaveAs folder & "\" & sht.Name & ".xlsx"
ActiveWorkbook.Close
end if
Next

Application.ScreenUpdating = True
End Sub