ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Adding new worksheet from template in code (https://www.excelbanter.com/excel-programming/294571-adding-new-worksheet-template-code.html)

E.J. van Wijngaarden

Adding new worksheet from template in code
 
Hello,

I need to be able to add a new worksheet from code, using an existing
(1-sheet) template.
I can only find code to open a complete new workbook using an exisiting
template.

Is this possible? If yes, how?

Thanks for your answers.

Ed van Wijngaarden



Bob Phillips[_6_]

Adding new worksheet from template in code
 
Hi Ed,

Create a template file as you require, and save it as a template file in the
Excel XLStart directory named Sheet. When you add a new sheet

ACtiveWorkbook.Worksheets.Add

it will be based upon this template.

Main problem, all sheets you add, in code or manually will have this
template. But new workbooks don't have to, you can create a separate
template file called Book for that, again in XLStart.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"E.J. van Wijngaarden" wrote in message
...
Hello,

I need to be able to add a new worksheet from code, using an existing
(1-sheet) template.
I can only find code to open a complete new workbook using an exisiting
template.

Is this possible? If yes, how?

Thanks for your answers.

Ed van Wijngaarden





Dave Peterson[_3_]

Adding new worksheet from template in code
 
This worked for me:

Sheets.Add Type:="c:\my documents\excel\book3.xls"

(don't use worksheets.add)



"E.J. van Wijngaarden" wrote:

Hello,

I need to be able to add a new worksheet from code, using an existing
(1-sheet) template.
I can only find code to open a complete new workbook using an exisiting
template.

Is this possible? If yes, how?

Thanks for your answers.

Ed van Wijngaarden


--

Dave Peterson



All times are GMT +1. The time now is 12:19 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com