Thread: Excel crashes
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Ron de Bruin Ron de Bruin is offline
external usenet poster
 
Posts: 11,123
Default Excel crashes

You can remove a few lines (I changed the sheet example from my site)

Sub Insert_Template()
Dim wb As Workbook
Dim wbName As String

'name of the template
wbName = "MyTemplate.xltm"

Set wb = Workbooks.Add(Template:=Application.TemplatesPath & wbName)

End Sub


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Ron de Bruin" wrote in message ...
Hi Fred

This is working for me for a file in the template folder

Sub Insert_Template()
Dim wb As Workbook
Dim wbName As String

'name of the template
wbName = "MyTemplate.xltm"

'Insert sheet template
With ThisWorkbook
Set wb = Workbooks.Add(Template:=Application.TemplatesPath & wbName)
End With

End Sub


See this page for sheet templates
http://www.rondebruin.nl/sheettemplate.htm

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Fred" <leavemealone@home wrote in message ...
Hi,

I am using Excel 2007 on Windows XP.

On the sheet I have a button (form button) that executes the macro below.
The macro runs fine, the new workbook (myTemplate1.xls) opens up OK.
The problem occurs when I close the workbook (myTemplate1.xls) Excel
crashes.
What am I doing wrong?

By the way I have been using myTemplate (opening it manually) for years
without a problem. It is only when I open it using the macro below that I
have this problem.

Thanks for any help
Fred


Sub Button432_Click()
Dim PartNo As String

PartNo = Trim(Sheet1.Range("C8").Value)
If PartNo < "" Then
Workbooks.Add Template:="\\myServer\myDrive\myTemplate.xlt"
End If
End Sub