Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Why is Excel 2003 changing the names of my macros??
I have a module which contains two Subs. The code of the 2nd Sub is given
below. Twice since I added the 2nd Sub, Excel has changed the names of the module's macros from the names I gave them to something like: WorkbookName!ModuleName.OldMacroName I see this changed name when looking at Excel (Not VBE) Tools/Macros/macro and also in the code. When other code tries to call the macros, Excel issues an error mesage saying it cannot find WorkbookName!ModuleName.OldMacroName even though that name exists in the code and in the list of maros. By process of elimination, I have found that simply changing the name of the 2nd sub corrects the problem. The 1st thme this occurred, I changed the name & the problem went away for awhile. When it came back, I changed the name again and it has gone away again - at least until ....? Nothing else I have tried fixes the problem, even removing all the code in the Sub. Why is this happening and how I can stop it? Many thanks for any help? Sub FirstName ' very simple code end sub Sub SecondName(OldName As String, NewName As String) Dim VBProj As VBIDE.VBProject Dim VBComp As VBIDE.VBComponent Dim CodeMod As VBIDE.CodeModule Dim Code As String Dim nCode As Long Set VBProj = ActiveWorkbook.VBProject Set VBComp = VBProj.VBComponents(Sheets(OldName).CodeName) Set CodeMod = VBComp.CodeModule 'Get number of lines of code in old sheet nCode = CodeMod.CountOfLines 'Get code starting at line 2 ' (Option explicit is already in new sheet) Code = CodeMod.Lines(2, nCode - 1) Set VBComp = VBProj.VBComponents(Sheets(NewName).CodeName) Set CodeMod = VBComp.CodeModule 'Write code to new sheet CodeMod.InsertLines 2, Code End Sub |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Why is Excel 2003 changing the names of my macros??
You don't say what OLDNAME and NEWNAME are? Also, what are the names of all
of the modules? -- HTH, Barb Reinhardt " wrote: I have a module which contains two Subs. The code of the 2nd Sub is given below. Twice since I added the 2nd Sub, Excel has changed the names of the module's macros from the names I gave them to something like: WorkbookName!ModuleName.OldMacroName I see this changed name when looking at Excel (Not VBE) Tools/Macros/macro and also in the code. When other code tries to call the macros, Excel issues an error mesage saying it cannot find WorkbookName!ModuleName.OldMacroName even though that name exists in the code and in the list of maros. By process of elimination, I have found that simply changing the name of the 2nd sub corrects the problem. The 1st thme this occurred, I changed the name & the problem went away for awhile. When it came back, I changed the name again and it has gone away again - at least until ....? Nothing else I have tried fixes the problem, even removing all the code in the Sub. Why is this happening and how I can stop it? Many thanks for any help? Sub FirstName ' very simple code end sub Sub SecondName(OldName As String, NewName As String) Dim VBProj As VBIDE.VBProject Dim VBComp As VBIDE.VBComponent Dim CodeMod As VBIDE.CodeModule Dim Code As String Dim nCode As Long Set VBProj = ActiveWorkbook.VBProject Set VBComp = VBProj.VBComponents(Sheets(OldName).CodeName) Set CodeMod = VBComp.CodeModule 'Get number of lines of code in old sheet nCode = CodeMod.CountOfLines 'Get code starting at line 2 ' (Option explicit is already in new sheet) Code = CodeMod.Lines(2, nCode - 1) Set VBComp = VBProj.VBComponents(Sheets(NewName).CodeName) Set CodeMod = VBComp.CodeModule 'Write code to new sheet CodeMod.InsertLines 2, Code End Sub . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macros Excel 2002 updating file names | Excel Discussion (Misc queries) | |||
How do I get 2003 Macros and Toolbar Buttons form Excel 2003 to 20 | New Users to Excel | |||
Changing names into email addresses using Excel/Visual Basic | Excel Programming | |||
changing file names with macros | Excel Programming | |||
Changing VB Component Names to match Worksheet names using VBE | Excel Programming |