Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
WEIRD - Excel is Changing the name of my macro
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 macros from the name 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 says it cannot find it and says the new macro cannot be found, even though it is in the list of macros. 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 aeay for awhile. When it came back, I changed the name again and it has gone away again - at least until ....? Does anyone have any idea why this is happening and how I can fix it? Many thanks. 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
|
|||
|
|||
WEIRD - Excel is Changing the name of my macro
|
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Weird Excel 2003 macro problem | Excel Discussion (Misc queries) | |||
Weird behavior with Macro VB window in Excel 2003 | Excel Programming | |||
weird macro | Excel Programming | |||
weird macro behavior | Excel Discussion (Misc queries) | |||
Macro is weird! | Excel Programming |