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 Excel crashes when program changes VBComponent name: Excel bug or what?

Running the code below in excel 97 VBA on a just opened new
workbook (book1.xls), then reopening the workbook after saving it
causes excel to crach before getting the book reopend.
It looks like the process of programatically changing the VBE
component name of a worksheet irreversibly corrupts
a workbook.

The code below is what I boiled down a bug that crept into
the process of cloning a workbook I was attempting create by
rebuilding all workbook components from scratch.
I was hoping to be able to reset all worksheet VBE component
names to the values as they were in the source book I was cloning.
(BTW, I can successfully reassign VBE names to user forms
and modules, just not worksheets)

I believe these names are rather cosmetic: So far I have not
seen any funcionality to using anything but the default ones
assigned when the sheets are created, but I find it nice to give them
more meaningful names for ease in navigating through the project
brower. Changing the names manually is no problem, but running the
code below definitle is . . .

Anybody run into this problem and have a work-around?

Here's the code:

Function ComponentofWS(ws As Worksheet) As VBComponent
Dim ThisProperty As Property
Dim SourceComponent As VBComponent, 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
Sub CorruptBook1()
ComponentofWS(Workbooks("book1.xls").Worksheets(1) ).Name = "Sheet2"
End Sub

|\|.
 
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
Is there a way to unload the loaded XLL file in Excel? Hi all, I amdebugging XLL link library using Visual C++. Everytime I rebuild the XLL, Ihave to close the whole Excel program and relaunch the Excel program again,and then load in the newly gene LunaMoon Excel Discussion (Misc queries) 0 July 28th 08 11:03 PM
Excel 2007 crashes with large linked Excel 2002 workbooks Adam Hector Excel Discussion (Misc queries) 0 May 22nd 08 02:47 PM
Computer crashes when Office program disc is inserted. Ron Weaver Excel Discussion (Misc queries) 2 September 8th 07 04:00 PM
Excel 2003 crashes loading excel files created Excel 2000 Jeff Lewin Australia Excel Discussion (Misc queries) 0 June 27th 05 04:20 AM
merging excel program with tdc finance program judy Excel Programming 0 November 5th 03 08:01 PM


All times are GMT +1. The time now is 05:08 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"