Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Inserting a worksheet based on a template
Of course this will also work
Sheets.Add Type:=Application.TemplatesPath & "\xxxxx.xlt" -- Regards Ron de Bruin http://www.rondebruin.nl "Ron de Bruin" wrote in message ... 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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Inserting a worksheet based on a template
Ron,
You seem to be omnipresent here in the world of Excel programming. So the Type parameter is more maleable than the documentation mentions. That's great. Thanks. James |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Crash when inserting a template | Excel Worksheet Functions | |||
inserting a row based on a condition. | Excel Worksheet Functions | |||
Inserting rows based on count | Excel Programming | |||
Inserting rows based on another cells value | Excel Programming | |||
Inserting rows based on another cells value | Excel Programming |