我有一个记录集UserTab
我要复制到Excel电子表格(它需要格式化)然后保存副本
Dim templatewb As Workbook
templatewb = application.open("C:\ \ .xlsx") // I also tried add
templatewb.Worksheets("Sheet1").Cells("A1").CopyFromRecordset UserTab
templatewb.close savechanges:=true filename:="c:...copyOfATemplate.xls"
我得到以下
Method 'Save' of object '_Workbook' failed
答案 0 :(得分:3)
Dim templatewb As Workbook
Set templatewb = workbooks.open("C:\stuff\templt.xlsx") 'need Set here...
templatewb.Worksheets("Sheet1").Range("A1").CopyFromRecordset UserTab
templatewb.SaveAs "C:\stuff\copyOfATemplate.xls"