Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Web Excel Component Bug | Excel Discussion (Misc queries) | |||
Changing ZIP code formats in Excel 2003 | Excel Discussion (Misc queries) | |||
Excel 2000: VB code for changing caseof text | Excel Programming | |||
Changing VB Component Names to match Worksheet names using VBE | Excel Programming | |||
Changing control properties/code through code | Excel Programming |