Excel 2013 cannot copy sheets
When I try to copy sheet manually to new workbook, Excel do nothing
When I try to copy sheet manually to end of workbook, Excel makes empty new sheet.
When I try to copy sheet with 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
I got error on ThisWorkbook.Worksheets("Baza").Copy
Run-time error '1004': copy method of worksheet class failed
How to Fix that?
尝试定义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/35764.html
上一篇: 复制工作表Excel VSTO C#
下一篇: Excel 2013不能复印工作表