Excel 2013不能复印工作表
当我尝试手动将工作表复印到新的工作簿时,Excel不会执行任何操作
当我尝试将工作表手动复制到工作簿结尾时,Excel会创建空的新工作表。
当我尝试使用VBA复制工作表时:
Sub TransEx()
Dim TemplatesFolder As String, FileName As String
TemplatesFolder = Replace(ThisWorkbook.FullName, ThisWorkbook.Name, "")
FileName = TemplatesFolder & "Transactions" & ".xlsx"
If Len(Dir(FileName)) <> 0 Then Kill FileName
ThisWorkbook.Worksheets("Baza").Copy
Application.ActiveWorkbook.SaveAs FileName, FileFormat:=51
End Sub
我在ThisWorkbook.Worksheets("Baza").Copy
上出错
运行时错误'1004':工作表类的复制方法失败
如何解决这个问题?
尝试定义Copy方法的目的地。
Sub TransEx()
Dim TemplatesFolder As String, FileName As String
TemplatesFolder = Replace(ThisWorkbook.FullName, ThisWorkbook.Name, "")
FileName = TemplatesFolder & "Transactions" & ".xlsx"
If Len(Dir(FileName)) <> 0 Then Kill FileName
Set wbO = Workbooks.Add
ThisWorkbook.Worksheets("Baza").Copy Before:=wbO.Sheets(1)
Application.ActiveWorkbook.SaveAs FileName, FileFormat:=51
End Sub
链接地址: http://www.djcxy.com/p/35763.html