Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

copy sheet from workbook into another workbook

Status
Not open for further replies.

Garrett546

Technical User
May 13, 2005
2
US
I am a begginer to VB anything and I know this has got to be a simple problem but i cant figure it out. How can i copy a sheet from an excel file to another workbook? The sheet contains a pivot table, a small formula table, and 2 charts. So I dont think i can copy a name range and have it work that way. I need to do this through a .vbs file so i can automate a report. Any help would be greatly appreciated.
 
Here is something i found in this forum that will change the order the sheets appear. I would imagine it would be somewhat simple to modify the code to do what im trying to do, i just dont know how to without getting all types of errors.


set oxl=createobject("Excel.Application")
oxl.visible=true
oxl.workbooks.open "d:\processor.xls"

set owb=oxl.activeworkbook

'move the first to [after] the last
owb.sheets(1).move ,owb.sheets(owb.sheets.count)
'move the now second sheet to [before] the first
owb.sheets(2).move owb.sheets(1)

'do other things
'close, clean up etc here omitted.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top