LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Templates and CreateObject

I have another MS app that opens Excel using the CreatObject method. I
also have a one sheet Excel workbook template saved as an *.xlt in a
folder on my "C" drive. If Excel is already open the following code
snippit will successfully replicate my pre-formatted template sheets as
many times as needed. However, if Excel is not already open and the
CreateObject Method is used, the template will open but the loop that
adds sheets does not replicate the pre-formatted first template sheet.
All I get is the one pre-formatted template sheet and the rest are
generic worksheets.

On Error Resume Next
'set up existing instance of Excel, or if Excel is not running, start it
Set XL = GetObject(, "Excel.application")
If Err < 0 Then
On Error GoTo 0
Set XL = CreateObject("Excel.Application")
End if
XL.Workbooks.Open FileName:="C:\myfolder\sheetform.xlt", Editable:=True
Set s = XL.Workbooks(ActiveWorkbook)
For i = 1 to n
s.Sheets.Add Type:="worksheet"
Next

Anyone have any suggestions?

John
 
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
saved templates opening as templates 4n6DNA Excel Discussion (Misc queries) 2 August 31st 09 09:30 PM
CreateObject("Excel.Application") Olivia Towery Excel Worksheet Functions 4 June 12th 06 12:07 AM
Createobject returns null in Excel [email protected] Excel Discussion (Misc queries) 1 March 27th 06 04:04 AM
Excel is opening templates as templates instead of as worksheets Desram Setting up and Configuration of Excel 1 January 19th 06 09:38 PM
CreateObject produces error Robert Chapman Excel Programming 0 August 15th 03 03:48 PM


All times are GMT +1. The time now is 06:38 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"