参考http://share.freesion.com/306372/可以实现直接拷贝指定表
- Private Sub Excel复制工作簿()
- Dim myExcelApp As New Microsoft.Office.Interop.Excel.Application
-
- myExcelApp.Workbooks.Open(System.Environment.CurrentDirectory + "\\测试用例.xlsx", Type.Missing)
- myExcelApp.Workbooks.Open(System.Environment.CurrentDirectory + "\\复制用例.xlsx", Type.Missing)
-
- Dim worksheet1 As Microsoft.Office.Interop.Excel.Worksheet = CType(myExcelApp.Workbooks(1).Worksheets(1), _
- Microsoft.Office.Interop.Excel.Worksheet)
- Dim worksheet2 As Microsoft.Office.Interop.Excel.Worksheet = CType(myExcelApp.Workbooks(2).Worksheets(1), _
- Microsoft.Office.Interop.Excel.Worksheet)
- worksheet1.Copy(After:=worksheet2)
-
- myExcelApp.Workbooks(2).Save()
- myExcelApp.Quit()
- myExcelApp = Nothing
-
- End Sub