Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 142
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default 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
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
Macros Excel 2002 updating file names cbaliles Excel Discussion (Misc queries) 1 March 31st 09 07:36 PM
How do I get 2003 Macros and Toolbar Buttons form Excel 2003 to 20 Scott Sornberger New Users to Excel 2 March 19th 08 11:42 AM
Changing names into email addresses using Excel/Visual Basic [email protected] Excel Programming 4 May 30th 06 05:50 PM
changing file names with macros trevor@OML Excel Programming 1 December 9th 05 04:21 PM
Changing VB Component Names to match Worksheet names using VBE Philip Excel Programming 1 April 12th 05 05:37 PM


All times are GMT +1. The time now is 01:37 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"