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: 11,123
Default Inserting a worksheet based on a template

Hi jstrater

Try something like this

Sub test()
Dim MyPath As String
Dim SaveDriveDir As String
Dim FileToOpen As Variant
SaveDriveDir = CurDir

MyPath = Application.TemplatesPath
ChDrive MyPath
ChDir MyPath
FileToOpen = Application.GetOpenFilename("Excel Templates (*.xlt),*.xlt")
If FileToOpen < False Then
Sheets.Add Type:=FileToOpen
End If

ChDrive SaveDriveDir
ChDir SaveDriveDir
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"jstrater" wrote in message ...
I do this all the time by right clicking on a sheet tab and selecting a template in the Insert Sheet dialog. But I don't see a

way to do this from code. The Sheets and Worksheets.Add method doesn't have a place to specify a template file name, and I don't
see any other methods for doing this. Is this just a glaring omission, or am I missing something? I'm using Excel XP (and
sometimes Excel 97)

---
James



 
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
Crash when inserting a template Razormanrick Excel Worksheet Functions 0 October 14th 06 07:27 PM
inserting a row based on a condition. Gary Excel Worksheet Functions 3 August 18th 06 02:09 PM
Inserting rows based on count Mike[_77_] Excel Programming 6 April 20th 04 11:14 PM
Inserting rows based on another cells value MikeT[_2_] Excel Programming 0 April 20th 04 07:47 PM
Inserting rows based on another cells value MikeT[_2_] Excel Programming 4 April 11th 04 10:08 PM


All times are GMT +1. The time now is 09:59 AM.

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

About Us

"It's about Microsoft Excel"