This project has moved and is read-only. For the latest updates, please go here.

Add new worksheet using template

Feb 28, 2013 at 6:36 PM

I'd like to add a new worksheet to the existing active workbook based on a template (.xltx). I can add a new workbook with
but this opens a new window. How can I load the template into the active book?

Mar 1, 2013 at 4:50 PM
It seems to be no method for direct loading template into workbook. You can open template and then copy worksheet into your workbook.
Mar 1, 2013 at 6:36 PM
You can do it from your workbook variable that you are currently working in:
Mar 1, 2013 at 11:01 PM
Edited Mar 1, 2013 at 11:09 PM
Thanks Jon49 it works!
Mar 1, 2013 at 11:12 PM
I was just doing a reply, but you beat me to it! For anyone that looks at this in the future this is how it should be done in .NET:

That's how you would type it in VBA. Sorry, I should have put it in .NET for you.
Excel.Application.Sheets.Add(Type.Missing,Type.Missing, Type.Missing, "TemplateWorkbookPath")
I'm not sure what would be the equivalent of Type.Missing in C#, that is in VB.
Jan 16, 2014 at 5:47 PM
Edited Jan 16, 2014 at 5:48 PM
System.Reflection.Missing _missing = System.Reflection.Missing.Value;
String path = @"path of excel";
Excel.Application.Sheets.Add(_missing ,_missing , _missing , path );
``` Regards