Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default Add worksheet as template

Hello,
I have an Excel/Word VBA app that uses templates for both. Trying to make it
compatible for Office 97 forward, I had a problem using the
Application.TemplatesPath to find the templates as the older and newer
versions use difference locations.
I am thinking perhaps the simplest solution is to do as one respondent said,
to just put my Word and Excel templates in my Program Files\Application
folder. I have Word templates and also Excel workbook and worksheet
templates. For the Word .dot and Excel Workbook templates I can then set the
path in the code. The only problem I am having now is trying to use the add
method of the Worksheet to add the worksheet template to a workbook.
The MS website doesn't give very specific instructions for adding a sheet as
a template. I have tried to add from my template after the last sheet such as:
Worksheets.Add.Move (after:=
Worksheets(Worksheets.Count),Type:="C:\Path\TEmpla teName.xlt")
and also
Worksheets.Add.Move Type:="C:\Path\TEmplateName.xlt"

However, I get error Application-defined or object-defined error message.
Any idea what the right syntax is to get this done.
Thanks again,
Van

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Add worksheet as template

Use Sheets.add instead of worksheets.add:

Sheets.Add Type:="C:\Path\TEmplateName.xlt"





VanS wrote:

Hello,
I have an Excel/Word VBA app that uses templates for both. Trying to make it
compatible for Office 97 forward, I had a problem using the
Application.TemplatesPath to find the templates as the older and newer
versions use difference locations.
I am thinking perhaps the simplest solution is to do as one respondent said,
to just put my Word and Excel templates in my Program Files\Application
folder. I have Word templates and also Excel workbook and worksheet
templates. For the Word .dot and Excel Workbook templates I can then set the
path in the code. The only problem I am having now is trying to use the add
method of the Worksheet to add the worksheet template to a workbook.
The MS website doesn't give very specific instructions for adding a sheet as
a template. I have tried to add from my template after the last sheet such as:
Worksheets.Add.Move (after:=
Worksheets(Worksheets.Count),Type:="C:\Path\TEmpla teName.xlt")
and also
Worksheets.Add.Move Type:="C:\Path\TEmplateName.xlt"

However, I get error Application-defined or object-defined error message.
Any idea what the right syntax is to get this done.
Thanks again,
Van


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default Add worksheet as template

Thanks, Dave. That worked.
I am trying to move the added sheet to the last postion in one step, using
the approximate syntax in some old Excel documention but get an error.

sheets.Add.Move (after:= Worksheets(Worksheets.Count), type:=
"C:\Path\TemplateSheet.xlt")
Do you know how to correct this, or how to do in one line, or do I have to
do in two steps?
Thanks again, God bless
Van
"Dave Peterson" wrote:

Use Sheets.add instead of worksheets.add:

Sheets.Add Type:="C:\Path\TEmplateName.xlt"





VanS wrote:

Hello,
I have an Excel/Word VBA app that uses templates for both. Trying to make it
compatible for Office 97 forward, I had a problem using the
Application.TemplatesPath to find the templates as the older and newer
versions use difference locations.
I am thinking perhaps the simplest solution is to do as one respondent said,
to just put my Word and Excel templates in my Program Files\Application
folder. I have Word templates and also Excel workbook and worksheet
templates. For the Word .dot and Excel Workbook templates I can then set the
path in the code. The only problem I am having now is trying to use the add
method of the Worksheet to add the worksheet template to a workbook.
The MS website doesn't give very specific instructions for adding a sheet as
a template. I have tried to add from my template after the last sheet such as:
Worksheets.Add.Move (after:=
Worksheets(Worksheets.Count),Type:="C:\Path\TEmpla teName.xlt")
and also
Worksheets.Add.Move Type:="C:\Path\TEmplateName.xlt"

However, I get error Application-defined or object-defined error message.
Any idea what the right syntax is to get this done.
Thanks again,
Van


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Add worksheet as template

Sheets.Add after:=Worksheets(Worksheets.Count), _
Type:="C:\Path\TemplateSheet.xlt"

worked ok for me.

(But it never bothered me using two steps either.)

VanS wrote:

Thanks, Dave. That worked.
I am trying to move the added sheet to the last postion in one step, using
the approximate syntax in some old Excel documention but get an error.

sheets.Add.Move (after:= Worksheets(Worksheets.Count), type:=
"C:\Path\TemplateSheet.xlt")
Do you know how to correct this, or how to do in one line, or do I have to
do in two steps?
Thanks again, God bless
Van
"Dave Peterson" wrote:

Use Sheets.add instead of worksheets.add:

Sheets.Add Type:="C:\Path\TEmplateName.xlt"





VanS wrote:

Hello,
I have an Excel/Word VBA app that uses templates for both. Trying to make it
compatible for Office 97 forward, I had a problem using the
Application.TemplatesPath to find the templates as the older and newer
versions use difference locations.
I am thinking perhaps the simplest solution is to do as one respondent said,
to just put my Word and Excel templates in my Program Files\Application
folder. I have Word templates and also Excel workbook and worksheet
templates. For the Word .dot and Excel Workbook templates I can then set the
path in the code. The only problem I am having now is trying to use the add
method of the Worksheet to add the worksheet template to a workbook.
The MS website doesn't give very specific instructions for adding a sheet as
a template. I have tried to add from my template after the last sheet such as:
Worksheets.Add.Move (after:=
Worksheets(Worksheets.Count),Type:="C:\Path\TEmpla teName.xlt")
and also
Worksheets.Add.Move Type:="C:\Path\TEmplateName.xlt"

However, I get error Application-defined or object-defined error message.
Any idea what the right syntax is to get this done.
Thanks again,
Van


--

Dave Peterson


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default Add worksheet as template

A bit late, but thanks again for your help Dave.
God bless
Van

"Dave Peterson" wrote:

Sheets.Add after:=Worksheets(Worksheets.Count), _
Type:="C:\Path\TemplateSheet.xlt"

worked ok for me.

(But it never bothered me using two steps either.)

VanS wrote:

Thanks, Dave. That worked.
I am trying to move the added sheet to the last postion in one step, using
the approximate syntax in some old Excel documention but get an error.

sheets.Add.Move (after:= Worksheets(Worksheets.Count), type:=
"C:\Path\TemplateSheet.xlt")
Do you know how to correct this, or how to do in one line, or do I have to
do in two steps?
Thanks again, God bless
Van
"Dave Peterson" wrote:

Use Sheets.add instead of worksheets.add:

Sheets.Add Type:="C:\Path\TEmplateName.xlt"





VanS wrote:

Hello,
I have an Excel/Word VBA app that uses templates for both. Trying to make it
compatible for Office 97 forward, I had a problem using the
Application.TemplatesPath to find the templates as the older and newer
versions use difference locations.
I am thinking perhaps the simplest solution is to do as one respondent said,
to just put my Word and Excel templates in my Program Files\Application
folder. I have Word templates and also Excel workbook and worksheet
templates. For the Word .dot and Excel Workbook templates I can then set the
path in the code. The only problem I am having now is trying to use the add
method of the Worksheet to add the worksheet template to a workbook.
The MS website doesn't give very specific instructions for adding a sheet as
a template. I have tried to add from my template after the last sheet such as:
Worksheets.Add.Move (after:=
Worksheets(Worksheets.Count),Type:="C:\Path\TEmpla teName.xlt")
and also
Worksheets.Add.Move Type:="C:\Path\TEmplateName.xlt"

However, I get error Application-defined or object-defined error message.
Any idea what the right syntax is to get this done.
Thanks again,
Van

--

Dave Peterson


--

Dave Peterson

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Template worksheet wcurtis Excel Discussion (Misc queries) 0 January 2nd 09 04:54 PM
Worksheet Template Janet T Excel Discussion (Misc queries) 8 June 6th 07 09:00 PM
Template question - can I replace the default "worksheet" template Jackie Excel Discussion (Misc queries) 2 April 19th 06 11:59 AM
Worksheet template Phippsy Excel Worksheet Functions 2 November 11th 05 10:13 AM
Create a template for every worksheet Alana Excel Discussion (Misc queries) 0 March 8th 05 09:49 PM


All times are GMT +1. The time now is 05:31 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"