Excel crashes

F

Fred

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
 
R

Ron de Bruin

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
 
R

Ron de Bruin

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
 
F

Fred

Thanks Ron,

I have been playing around a bit more and it doesn't seem to be related to
the macro at all. Even if I open each of these workbooks manually then close
one it crashes Excel yet each workbook works fine by itself and they both
work fine with other workbooks.
I know it sounds strange. I find it hard to believe but I have tried all
sorts of combinations of various workbooks and it only happens when both of
these workbooks are open and it happens every time. Other than the macro for
the button, there is no other link between the workbooks.
It even happens when one of the workbooks is opened in a different instance
of Excel although this does seem to intermitant.

I'd appreciate any idea on what could cause this.

Thanks
Fred
 
F

Fred

Hi Ron,

Yes there is code in the template but the code is only macros associated
with buttons. I don't click any of the buttons so none of the code is
actually run.
Both workbooks do have data connections using the same DSN but I have tried
both workbooks with other workbooks with similar connections and there is no
problem with other combinations of workbooks.

Fred
 
F

Fred

Thanks Ron,

Re-compiling the workbook didn't help but I removed all of the modules then
copied the programs back to new modules and that did fix the problem.

Regards,
Fred
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top