excle sheet 拷贝
Dim TeamTemplateSheet As ObjectDim XlsApp As Object
Dim XlsBook As Excel.Workbook
Dim XlsSheet As Excel.Worksheet
Set XlsApp = CreateObject("Excel.Application")
XlsApp.Visible = False
Set XlsBook = XlsApp.Workbooks.Add
Set XlsSheet = XlsBook.Worksheets(1)
我想将 "aaa.xls"中sheet名为"shee1"中全部内容和形式,拷贝到XlsSheet 中,如何实现?
XlsSheet.SaveAs "D:\aaaaa.xls" --------------------编程问答-------------------- copy 命令
--------------------编程问答-------------------- 试下下面的代码
Set destinateObject = CreateObject("Excel.Sheet")
outputFilePath = "D:\aaaaa.xls "
Set destinateObject = Workbooks.Add
destinateObject.SaveAs fileName:=outputFilePath
destinateObject.Application.Workbooks.Open "c:\aaa.xls "
Sheets("newSHEETNAME").Copy Before:=Worksheets("Sheet1") --------------------编程问答-------------------- 这是我试验过的,好用的.
Dim destinateFileName As String
Dim destinateObject As Object
Dim defaultFileName As String
Dim templateFilePath As String
Dim outputFilePath As String
Dim outputFile As String
Dim xmlFileName As String
Dim excelSheet As String
On Error GoTo Err_Deal
Set destinateObject = CreateObject("Excel.Sheet")
outputFilePath = "c:\aaabbb.xls"
outputFile = "aaabbb.xls"
templateFilePath = "c:\aaa.xls"
defaultFileName = "aaa.xls"
excelSheet = "test"
Set destinateObject = Workbooks.Add
destinateObject.SaveAs fileName:=outputFilePath
destinateObject.Application.Workbooks.Open templateFilePath
Sheets(excelSheet).Copy Before:=Workbooks(outputFile).Sheets(1)
Workbooks(defaultFileName).Close
Workbooks(outputFile).Close
Set destinateObject = Nothing
Exit Sub
Err_Deal:
ActiveWindow.Close
Application.DisplayAlerts = True
Set destinateObject = Nothing --------------------编程问答-------------------- --------------------编程问答-------------------- --------------------编程问答--------------------
补充:VB , 基础类