LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Changing VBE WS-component name in code craches excel 97

Changing the VBE component name of any worksheet, as illustrated
in the sample code below predictably crashes my installation of excel
97.
I can do it manually without a problem, but . . .

Anyboy seen something like this before? If not try it . . . this looks
like an MS bug to me.
I'm running on Windows XP Professional Version 5.1 (Build
2600.xpsp2.050301-1526: Service Pack 1)
523 MB Ram

(Of course you have to add a reference to: "Microsoft Visual Basic for
Applications Extensibility")
________________________________________________

Sub MakeACorruptWorkbook()
'
' Warning: Run it and you *will* crash this excel 97 session !!!
'
Dim WSname As String
Workbooks.Add
ComponentofWS(ActiveWorkbook.Worksheets(1)).Name = "Sheet2"
Application.DisplayAlerts = False
ActiveWorkbook.Save
Application.DisplayAlerts = True
WSname = ActiveWorkbook.FullName
ActiveWorkbook.Close
Workbooks.Open FileName:=WSname ' What bomb just went off ???
End Sub

Function ComponentofWS(ws As Worksheet) As VBComponent
Dim ThisProperty As Property
Dim SourceComponent As VBComponent
Dim SourceComponents As VBComponents
Set SourceComponents = ws.Parent.VBProject.VBComponents
For Each SourceComponent In SourceComponents
If SourceComponent.Type = vbext_ct_Document Then
For Each ThisProperty In SourceComponent.Properties
If ThisProperty.Name = "Name" Then
If ThisProperty.Value = ws.Name Then
Set ComponentofWS = SourceComponent
Exit Function
End If
End If
Next
End If
Next
End Function
 
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
Web Excel Component Bug [email protected] Excel Discussion (Misc queries) 1 May 11th 07 12:22 AM
Changing ZIP code formats in Excel 2003 cdbinder Excel Discussion (Misc queries) 6 January 29th 07 03:04 AM
Excel 2000: VB code for changing caseof text pgnl Excel Programming 3 December 1st 05 07:05 PM
Changing VB Component Names to match Worksheet names using VBE Philip Excel Programming 1 April 12th 05 05:37 PM
Changing control properties/code through code Ajit Excel Programming 3 October 18th 04 09:03 PM


All times are GMT +1. The time now is 02:14 AM.

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"