Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
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 | Excel Discussion (Misc queries) | |||
Excel 2007 crashes with large linked Excel 2002 workbooks | Excel Discussion (Misc queries) | |||
Computer crashes when Office program disc is inserted. | Excel Discussion (Misc queries) | |||
Excel 2003 crashes loading excel files created Excel 2000 | Excel Discussion (Misc queries) | |||
merging excel program with tdc finance program | Excel Programming |