Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 175
Default Bug - Add OLE Object to Worksheet crashes out Excel 2002 SP3

Has anyone else seen this bug that crashes out Excel?

PC: Windows XP Pro SP1, Office XP SP3, HP wx6000 workstation.

To replicate:

Cut and paste the code between the dotted lines to a new module and run it.
Ignore the variable names corrupt and so on, that means corrupt data at the
business level in the workbook, not a corrupt .xls file.

Run this code by clicking through and leave the cursor on the line
"lngIncrementThroughCleanWorkbook = 1"

Now, switch to the Excel user interface and try and add an ActiveX control
button. Boom, excel bombs out. I've tried on two PCs here with the same
results. I can probably work around this in a different way, so it's not as
deal breaker, but it's better bad that Excel dies like this.

Any one from Microsoft want to investigate???







------------------------------------------------------------------------------------------------
'Constants
Const strMethodName As String = "Engineering.CorruptWorkBookRebuilder "
Const strInputBoxTitle As String = "Select the broken file"
Const strInputBoxButtonCaption As String = "Fix"
'Variables
Dim oCorruptName As Excel.Name
Dim strCorruptWorkbookName As String
Dim strCleanWorkbookName As String
Dim lngNumberofSheetsInNewWorkbook As Long
Dim lngNumberOfWorksheetsInCorruptWorkbook As Long
Dim lngDefaultNumberOfWorksheetsInWorkbook As Long
Dim lfso As Scripting.FileSystemObject
Dim lngIncrementThroughCleanWorkbook As Long
Dim oCorruptWorkSheet As Excel.Worksheet
Dim oCleanWorksheet As Excel.Worksheet
Dim lvbMsgBoxResult As VBA.VbMsgBoxResult



CorruptWorkBookRebuilder = False

Set lfso = New Scripting.FileSystemObject

lvbMsgBoxResult = MsgBox("You need to ensure that the corrupt workbook is in
a directory with no other files or folders. Is this the case?", vbCritical +
vbYesNo, strMethodName)

If lvbMsgBoxResult = vbYes Then

strCorruptWorkbookName = Application.GetOpenFilename(, ,
strInputBoxTitle, strInputBoxButtonCaption, False)

With Application
.EnableEvents = False
.Calculation = xlCalculationManual
.IgnoreRemoteRequests = True
.DisplayAlerts = False
End With

Set moCorruptWorkbook =
Application.Workbooks.Open(strCorruptWorkbookName, 0, True, , , , , , , , , ,
False)

lngNumberOfWorksheetsInCorruptWorkbook =
moCorruptWorkbook.Worksheets.Count

lngDefaultNumberOfWorksheetsInWorkbook = Application.SheetsInNewWorkbook
Application.SheetsInNewWorkbook = lngNumberOfWorksheetsInCorruptWorkbook


Set moCleanWorkbook = Application.Workbooks.Add

strCleanWorkbookName = lfso.GetBaseName(moCorruptWorkbook.Name)
strCleanWorkbookName = strCleanWorkbookName & "_RECOVERED" &
lfso.GetExtensionName(moCorruptWorkbook.Name)
strCleanWorkbookName = lfso.BuildPath(moCorruptWorkbook.Path,
strCleanWorkbookName)

moCleanWorkbook.SaveAs strCleanWorkbookName
lngIncrementThroughCleanWorkbook = 1
else
end if
------------------------------------------------------------------------------------------------






--
www.alignment-systems.com
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Bug - Add OLE Object to Worksheet crashes out Excel 2002 SP3

Hi John,

Afraid I can't make sense of the code in relation to the problem but your
subject line strongly reminds me of a comment made by Stephen Bullen -

http://tinyurl.com/ouj4k

In essence the workbook recompiles as the control is added, which I've since
been able to relate to various other scenarios.

Regards,
Peter T

"John.Greenan" wrote in message
...
Has anyone else seen this bug that crashes out Excel?

PC: Windows XP Pro SP1, Office XP SP3, HP wx6000 workstation.

To replicate:

Cut and paste the code between the dotted lines to a new module and run

it.
Ignore the variable names corrupt and so on, that means corrupt data at

the
business level in the workbook, not a corrupt .xls file.

Run this code by clicking through and leave the cursor on the line
"lngIncrementThroughCleanWorkbook = 1"

Now, switch to the Excel user interface and try and add an ActiveX control
button. Boom, excel bombs out. I've tried on two PCs here with the same
results. I can probably work around this in a different way, so it's not

as
deal breaker, but it's better bad that Excel dies like this.

Any one from Microsoft want to investigate???







--------------------------------------------------------------------------

----------------------
'Constants
Const strMethodName As String = "Engineering.CorruptWorkBookRebuilder "
Const strInputBoxTitle As String = "Select the broken file"
Const strInputBoxButtonCaption As String = "Fix"
'Variables
Dim oCorruptName As Excel.Name
Dim strCorruptWorkbookName As String
Dim strCleanWorkbookName As String
Dim lngNumberofSheetsInNewWorkbook As Long
Dim lngNumberOfWorksheetsInCorruptWorkbook As Long
Dim lngDefaultNumberOfWorksheetsInWorkbook As Long
Dim lfso As Scripting.FileSystemObject
Dim lngIncrementThroughCleanWorkbook As Long
Dim oCorruptWorkSheet As Excel.Worksheet
Dim oCleanWorksheet As Excel.Worksheet
Dim lvbMsgBoxResult As VBA.VbMsgBoxResult



CorruptWorkBookRebuilder = False

Set lfso = New Scripting.FileSystemObject

lvbMsgBoxResult = MsgBox("You need to ensure that the corrupt workbook is

in
a directory with no other files or folders. Is this the case?",

vbCritical +
vbYesNo, strMethodName)

If lvbMsgBoxResult = vbYes Then

strCorruptWorkbookName = Application.GetOpenFilename(, ,
strInputBoxTitle, strInputBoxButtonCaption, False)

With Application
.EnableEvents = False
.Calculation = xlCalculationManual
.IgnoreRemoteRequests = True
.DisplayAlerts = False
End With

Set moCorruptWorkbook =
Application.Workbooks.Open(strCorruptWorkbookName, 0, True, , , , , , , ,

, ,
False)

lngNumberOfWorksheetsInCorruptWorkbook =
moCorruptWorkbook.Worksheets.Count

lngDefaultNumberOfWorksheetsInWorkbook =

Application.SheetsInNewWorkbook
Application.SheetsInNewWorkbook =

lngNumberOfWorksheetsInCorruptWorkbook


Set moCleanWorkbook = Application.Workbooks.Add

strCleanWorkbookName = lfso.GetBaseName(moCorruptWorkbook.Name)
strCleanWorkbookName = strCleanWorkbookName & "_RECOVERED" &
lfso.GetExtensionName(moCorruptWorkbook.Name)
strCleanWorkbookName = lfso.BuildPath(moCorruptWorkbook.Path,
strCleanWorkbookName)

moCleanWorkbook.SaveAs strCleanWorkbookName
lngIncrementThroughCleanWorkbook = 1
else
end if
--------------------------------------------------------------------------

----------------------






--
www.alignment-systems.com



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
Named formula crashes Excel 2002 instantly Dallman Ross Excel Discussion (Misc queries) 2 September 3rd 07 06:04 PM
Japanese Excel 2002 crashes because of CoTaskMemFree, why? Dave Rafkind Excel Programming 0 March 15th 05 03:45 PM
Excel 2002 crashes Veena New Users to Excel 0 February 16th 05 10:29 AM
Excel 2002 Crashes Veena Excel Programming 0 February 16th 05 10:26 AM
Why Excel 2002 crashes on simplest Workbook_Open events? RADO[_3_] Excel Programming 1 November 8th 03 09:31 PM


All times are GMT +1. The time now is 02:11 PM.

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

About Us

"It's about Microsoft Excel"