courchjo
asked on
How can you move excel worksheets across different excel work books?
Can anyone let me know if there is a way to add one excel workbook’s excel worksheet to another excel workbook.
The following is the code I have done. But I am getting an error on the following line
xlApp.Sheets.Move(, xlSheetBranchTemp)
This is the code I am using ---------------->
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheetTemp As Excel.Worksheet
xlApp = CreateObject("Excel.Applic ation")
xlApp.DisplayAlerts = False
xlBook = xlApp.Workbooks.Open("c:\T est4.xls")
Dim xlAppBranch As New Excel.Application
Dim xlBookBranch As Excel.Workbook
Dim xlSheetBranchTemp As Excel.Worksheet
xlBookBranch = xlAppBranch.Workbooks.Open ("c:\Test5 .xls")
xlSheetBranchTemp = xlAppBranch.ActiveWorkbook .Worksheet s(1)
xlSheetBranchTemp.Select()
xlApp.Sheets.Move(, xlSheetBranchTemp)
xlApp.ActiveWorkbook.Works heets.Item (1).name = "Summary"
xlApp.ActiveWorkbook.Works heets.Item (2).name = "Branch1"
xlBookBranch.Close()
xlAppBranch = Nothing
xlBook.SaveAs("c:\Test4.xl s")
xlBook.Close()
xlApp = Nothing
The following is the code I have done. But I am getting an error on the following line
xlApp.Sheets.Move(, xlSheetBranchTemp)
This is the code I am using ---------------->
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheetTemp As Excel.Worksheet
xlApp = CreateObject("Excel.Applic
xlApp.DisplayAlerts = False
xlBook = xlApp.Workbooks.Open("c:\T
Dim xlAppBranch As New Excel.Application
Dim xlBookBranch As Excel.Workbook
Dim xlSheetBranchTemp As Excel.Worksheet
xlBookBranch = xlAppBranch.Workbooks.Open
xlSheetBranchTemp = xlAppBranch.ActiveWorkbook
xlSheetBranchTemp.Select()
xlApp.Sheets.Move(, xlSheetBranchTemp)
xlApp.ActiveWorkbook.Works
xlApp.ActiveWorkbook.Works
xlBookBranch.Close()
xlAppBranch = Nothing
xlBook.SaveAs("c:\Test4.xl
xlBook.Close()
xlApp = Nothing
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hey courchjo
You are welcome
one more comment
if you use vb.net, Microsft has wrapped excell for you as an assembly instead of Com, so you can use
Microsoft.Office.Interop.E xcel
have a nice day
Yotam
You are welcome
one more comment
if you use vb.net, Microsft has wrapped excell for you as an assembly instead of Com, so you can use
Microsoft.Office.Interop.E
have a nice day
Yotam
ASKER
Thanks again.