View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ron de Bruin Ron de Bruin is offline
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