ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Load Template (https://www.excelbanter.com/excel-programming/374851-load-template.html)

rahul

Load Template
 
1. Is it possible to load a Excel template in an existing workbook?
2. Also, is it possible to know from the workbook which template it has
loaded?

I used Application.WorkBooks.Add() but this opens a new workbook.

Bob Phillips

Load Template
 
You can specify the template to open as an argument to Workbooks.Add

Workbooks.Add Template:="C:\Templates\myTemplate.xlt"

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"rahul" wrote in message
...
1. Is it possible to load a Excel template in an existing workbook?
2. Also, is it possible to know from the workbook which template it has
loaded?

I used Application.WorkBooks.Add() but this opens a new workbook.




rahul

Load Template
 
I want to load a template in an existing workbook!

"Bob Phillips" wrote:

You can specify the template to open as an argument to Workbooks.Add

Workbooks.Add Template:="C:\Templates\myTemplate.xlt"

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"rahul" wrote in message
...
1. Is it possible to load a Excel template in an existing workbook?
2. Also, is it possible to know from the workbook which template it has
loaded?

I used Application.WorkBooks.Add() but this opens a new workbook.





NickHK

Load Template
 
You could try recording a macro of this action.
You would get something like:
Sheets.Add Type:="C:\Path to your templates\Template.xlt"

NickHK

"rahul" wrote in message
...
I want to load a template in an existing workbook!

"Bob Phillips" wrote:

You can specify the template to open as an argument to Workbooks.Add

Workbooks.Add Template:="C:\Templates\myTemplate.xlt"

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"rahul" wrote in message
...
1. Is it possible to load a Excel template in an existing workbook?
2. Also, is it possible to know from the workbook which template it

has
loaded?

I used Application.WorkBooks.Add() but this opens a new workbook.







rahul

Load Template
 
Can you let me know the parameter to be passed in C#?
I am getting an exception. The API signature is

object Add(
[In, Optional] object Before,
[In, Optional] object After,
[In, Optional] object Count,
[In, Optional] object Type
);

I dont know what to pass in the fourth parameter. I passed the template
location but I am getting an exception 0x800A03EC.

I am making this api call
application.ActiveWorkbook.Worksheets.Add(Type.Mis sing,Type.Missing,Type.Missing,
@"c:\Documents and Settings\raverma\My Documents\Visual Studio
2005\Projects\ExcelWordAddins\Sample.xlt");
"NickHK" wrote:

You could try recording a macro of this action.
You would get something like:
Sheets.Add Type:="C:\Path to your templates\Template.xlt"

NickHK

"rahul" wrote in message
...
I want to load a template in an existing workbook!

"Bob Phillips" wrote:

You can specify the template to open as an argument to Workbooks.Add

Workbooks.Add Template:="C:\Templates\myTemplate.xlt"

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"rahul" wrote in message
...
1. Is it possible to load a Excel template in an existing workbook?
2. Also, is it possible to know from the workbook which template it

has
loaded?

I used Application.WorkBooks.Add() but this opens a new workbook.







NickHK

Load Template
 
You have to use the .Sheets collection not the .Worksheets collection.

Otherwise the Worksheets.Add method expects, for Type:
<From Help
Type Optional Variant. Specifies the sheet type. Can be one of the
following XlSheetType constants: xlWorksheet, xlChart, xlExcel4MacroSheet,
or xlExcel4IntlMacroSheet. The default value is xlWorksheet.
</From Help
Although the help is not clear on the above difference.

You could get your code working in Excel, with the help of the macro
recorder and Object Browser first, to use the correct syntax, methods etc,
then translate to C#.

NickHK

"rahul" wrote in message
...
Can you let me know the parameter to be passed in C#?
I am getting an exception. The API signature is

object Add(
[In, Optional] object Before,
[In, Optional] object After,
[In, Optional] object Count,
[In, Optional] object Type
);

I dont know what to pass in the fourth parameter. I passed the template
location but I am getting an exception 0x800A03EC.

I am making this api call

application.ActiveWorkbook.Worksheets.Add(Type.Mis sing,Type.Missing,Type.Mis
sing,
@"c:\Documents and Settings\raverma\My Documents\Visual Studio
2005\Projects\ExcelWordAddins\Sample.xlt");
"NickHK" wrote:

You could try recording a macro of this action.
You would get something like:
Sheets.Add Type:="C:\Path to your templates\Template.xlt"

NickHK

"rahul" wrote in message
...
I want to load a template in an existing workbook!

"Bob Phillips" wrote:

You can specify the template to open as an argument to Workbooks.Add

Workbooks.Add Template:="C:\Templates\myTemplate.xlt"

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"rahul" wrote in message
...
1. Is it possible to load a Excel template in an existing

workbook?
2. Also, is it possible to know from the workbook which template

it
has
loaded?

I used Application.WorkBooks.Add() but this opens a new workbook.










All times are GMT +1. The time now is 01:42 AM.

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