Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ben Ben is offline
external usenet poster
 
Posts: 509
Default Runs Fine In Step Mode But Crashes Excel Otherwise

I have a set of code to save a certain workbook changes, when i run it in
step mode (F8). The code works without a single problem, not even needing to
resort to my error handling. When I run it from the Embedded control on the
worksheet that activates, it will not run in the background and simply
crashes Excel every single time. HELP!!! I have included the sub below:


On Error GoTo oops
Application.ScreenUpdating = False
msg = "Are you sure you want to save these changes to your Resale SOF?"
Style = vbYesNo + vbDefaultButton2
title = "Save?"
Response = MsgBox(msg, Style, title)
ini = Range("e3").Value
If taxx = True Then taxx1 = True
If taxx = False Then taxx1 = False
nob = ThisWorkbook.Name
If Response = vbYes Then
With ActiveWorkbook.Sheets(1).Range("AA15:AC22")
.Font.Size = 10
.Font.ColorIndex = 0
.ClearContents
End With
ActiveWorkbook.Sheets(1).Cells(Sheets(1).Range("ao 1").Value + 61,
13).Value = ""
ActiveWorkbook.Sheets(1).Range("x1").Value = ini
ActiveWorkbook.Sheets(1).Activate
If taxx1 = True Then ActiveWorkbook.Sheets(1).TAXEX = True
If taxx1 = False Then ActiveWorkbook.Sheets(1).TAXEX = False
Sheets(1).Range("ac9").Value = ""
ActiveSheet.Range("d2").Select
On Error Resume Next
Kill "C:\lists\Resale SOF.xlt"
Kill "c:\lists\123.xls"
On Error GoTo oops
Workbooks(nob).SaveAs Filename:="c:\lists\Resale SOF.xlt"
Workbooks("Resale SOF.xlt").SaveAs Filename:="c:\lists\123.xls"
ActiveWorkbook.Sheets(1).Activate
ThisWorkbook.Workbook_Open
Else
Application.ScreenUpdating = True
Exit Sub
End If
Application.ScreenUpdating = True
Exit Sub
oops:
MsgBox "I'm sorry this is a problem saving your changes. " +
Str(Err.Number) + "-" + Err.Description
Application.ScreenUpdating = True


P.S. Yeah I know the code is simple but i learned computers with Old Basic :p)
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Runs Fine In Step Mode But Crashes Excel Otherwise

Without looking at your code (only your description)...

There's a bug in xl97 that concerns macros called from controls placed on a
worksheet (from the control toolbox toolbar).

If that's the case with you (like a commandbutton), you can change the control's
takefocusonclick property to false.

Or add:

activecell.activate

to the top of your procedure.

If that's not it, you may want to post the portion of the code that's blowing up
and how it's initiated.



ben wrote:

I have a set of code to save a certain workbook changes, when i run it in
step mode (F8). The code works without a single problem, not even needing to
resort to my error handling. When I run it from the Embedded control on the
worksheet that activates, it will not run in the background and simply
crashes Excel every single time. HELP!!! I have included the sub below:

On Error GoTo oops
Application.ScreenUpdating = False
msg = "Are you sure you want to save these changes to your Resale SOF?"
Style = vbYesNo + vbDefaultButton2
title = "Save?"
Response = MsgBox(msg, Style, title)
ini = Range("e3").Value
If taxx = True Then taxx1 = True
If taxx = False Then taxx1 = False
nob = ThisWorkbook.Name
If Response = vbYes Then
With ActiveWorkbook.Sheets(1).Range("AA15:AC22")
.Font.Size = 10
.Font.ColorIndex = 0
.ClearContents
End With
ActiveWorkbook.Sheets(1).Cells(Sheets(1).Range("ao 1").Value + 61,
13).Value = ""
ActiveWorkbook.Sheets(1).Range("x1").Value = ini
ActiveWorkbook.Sheets(1).Activate
If taxx1 = True Then ActiveWorkbook.Sheets(1).TAXEX = True
If taxx1 = False Then ActiveWorkbook.Sheets(1).TAXEX = False
Sheets(1).Range("ac9").Value = ""
ActiveSheet.Range("d2").Select
On Error Resume Next
Kill "C:\lists\Resale SOF.xlt"
Kill "c:\lists\123.xls"
On Error GoTo oops
Workbooks(nob).SaveAs Filename:="c:\lists\Resale SOF.xlt"
Workbooks("Resale SOF.xlt").SaveAs Filename:="c:\lists\123.xls"
ActiveWorkbook.Sheets(1).Activate
ThisWorkbook.Workbook_Open
Else
Application.ScreenUpdating = True
Exit Sub
End If
Application.ScreenUpdating = True
Exit Sub
oops:
MsgBox "I'm sorry this is a problem saving your changes. " +
Str(Err.Number) + "-" + Err.Description
Application.ScreenUpdating = True

P.S. Yeah I know the code is simple but i learned computers with Old Basic :p)


--

Dave Peterson
Reply
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
VBA macro runs fine, but freezes if I try to do ANYTHING else whileit runs Rruffpaw Setting up and Configuration of Excel 1 September 17th 11 01:25 PM
Excel Macro runs fine, but freezes if I try to do ANYTHING else whileit's running Rruffpaw Setting up and Configuration of Excel 0 August 3rd 11 08:31 PM
how do u fine picture tool for the rose on Excel step 6-6? Elecia Excel Discussion (Misc queries) 1 November 1st 08 05:42 AM
xls file works fine in Excel 2000 and 2007 but crashes on opening in 2003 gromit12 Excel Discussion (Misc queries) 2 November 6th 07 09:30 PM
Excel only runs in Safe Mode. Michael Koerner Excel Programming 5 September 14th 03 01:30 PM


All times are GMT +1. The time now is 01:36 PM.

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

About Us

"It's about Microsoft Excel"