HI All,
I have a excel workbook which contains 6-7 sheets. i want to write a vba code .. so that when i run, it should create a new work book on my desktop and import all the 7 sheets from the source Workbook.
Regards
Kumar
HI All,
I have a excel workbook which contains 6-7 sheets. i want to write a vba code .. so that when i run, it should create a new work book on my desktop and import all the 7 sheets from the source Workbook.
Regards
Kumar
Just use the following with the workbook open (and put in your desktop path with the file-name)
[vba]ActiveWorkbook.SaveCopyAs "c:\newworkbook.xls"[/vba]
_________________________________________________________________________
"In theory there is no difference between theory and practice. In practice there is." - Chuck Reid
Any day you learn something new is a day not wasted.
Sub ImportTemplate()
FileCopy "c:\Adventure.xlsm", _
ActiveWorkbook.Path & "Adventureworks.xlsm"
Name "C:\WorkedAdventist.xlsm" As "C:\Documents and Settings\All users\Desktop\Adventist.xlsm"
End Sub
Please use the VBA tags to post code (it's easier to read).
How you do it depends where you want to contain the code. If it's in a separate workbook it's OK but if it's in the file you want to copy you'll generate an error as it's already open. You might also get some unexpected results if there's more than one workbook open as the active one may not be the one you think. If you're referring to the workbook running code use "ThisWorkbook" instead.
_________________________________________________________________________
"In theory there is no difference between theory and practice. In practice there is." - Chuck Reid
Any day you learn something new is a day not wasted.