Hi,
I want to copy over the open workbook to a new template file but i got the run time "9" error.
I hope someone can assist me to fix the error.Sub CopySheets() Dim WB As Workbook Dim WB2 As Workbook Set WB = ThisWorkbook Workbooks.Add Template:="C:\xxx.xltm" Set WB2 = Workbooks("xxx.xlsm") WB.Sheets.Copy Before:=WB2.Sheets(1) End Sub
Thank you in advance.
Last edited by Apple Ling; 07-07-2011 at 02:10 AM.
Anyone help please.
for Excel 2003 template workbook:
Sub test() Application.ScreenUpdating = 0 With ActiveWorkbook: .Sheets.Copy: .SaveAs "C:\Temp.xlt": End With Application.ScreenUpdating = 1 End Sub
maybe
Sub CopySheets() Dim WB As Workbook Dim WB2 As Workbook Set WB = ThisWorkbook Workbooks.Add Template:="C:\xxx.xltm" Set WB2 = ActiveWorkbook WB.Sheets.Copy Before:=WB2.Sheets(1) End Sub
Hope that helps.
RoyUK
--------
If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need
For Excel Tips & Solutions, free examples and tutorials why not check out my downloads
New members please read & follow the Forum Rules
Remember to mark your questions Solved and rate the answer(s)
Thank you very much. It's works fine now![]()
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks