请问EXCEL2007 VBA代码怎么编写将单个工作表另存文件,最好不自动生成和自动生成文件两种情况都要,谢谢
1个回答
展开全部
Option Explicit
Sub SheetCopy()
On Error GoTo line
ActiveSheet.Copy
ActiveWorkbook.Close SaveChanges:=True, Filename:=ThisWorkbook.Path & "\SheetCopy.xls"
Exit Sub
line:
ActiveWorkbook.Close False
End Sub
Sub ArrSheetCopy()
On Error GoTo line
Worksheets(Array("Sheet1", "Sheet2")).Copy
ActiveWorkbook.SaveAs Filename:=ThisWorkbook.Path & "\ArrSheetCopy.xls"
ActiveWorkbook.Close SaveChanges:=True
Exit Sub
line:
ActiveWorkbook.Close False
End Sub
Sub SheetCopy()
On Error GoTo line
ActiveSheet.Copy
ActiveWorkbook.Close SaveChanges:=True, Filename:=ThisWorkbook.Path & "\SheetCopy.xls"
Exit Sub
line:
ActiveWorkbook.Close False
End Sub
Sub ArrSheetCopy()
On Error GoTo line
Worksheets(Array("Sheet1", "Sheet2")).Copy
ActiveWorkbook.SaveAs Filename:=ThisWorkbook.Path & "\ArrSheetCopy.xls"
ActiveWorkbook.Close SaveChanges:=True
Exit Sub
line:
ActiveWorkbook.Close False
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询