Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Need Code to rename standard modules


Can someone kindly help me out with a code to *rename* standard modules?
I have googled in vain for leads. Even Chip Pearson seemed to have miss
this one in his comprehensive coverage of codings to manipulate
VBComponents.

[I intend using the first 8 or so characters of ProcedureTitles to
rename meaningfully and can quite comfortably handle this bit of
extracting the characters].

TIA

David


--
davidm
------------------------------------------------------------------------
davidm's Profile: http://www.excelforum.com/member.php...o&userid=20645
View this thread: http://www.excelforum.com/showthread...hreadid=526630

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 747
Default Need Code to rename standard modules

You probably know this but ensure that the Microsoft Visual Basic for
Applications Extensibility reference is selected before running the code:

Sub RenameMods()
Dim vbmod As VBComponent
For Each vbmod In ThisWorkbook.VBProject.VBComponents
If vbmod.Type = vbext_ct_StdModule Then
Select Case vbmod.Name
Case "Module1"
vbmod.Name = "HelloWorld_1"
Case "Module2"
vbmod.Name = "HelloWorld_2"
Case "Module3"
vbmod.Name = "HelloWorld_3"
End Select
End If
Next
End Sub

Regards,
Greg

"davidm" wrote:


Can someone kindly help me out with a code to *rename* standard modules?
I have googled in vain for leads. Even Chip Pearson seemed to have miss
this one in his comprehensive coverage of codings to manipulate
VBComponents.

[I intend using the first 8 or so characters of ProcedureTitles to
rename meaningfully and can quite comfortably handle this bit of
extracting the characters].

TIA

David


--
davidm
------------------------------------------------------------------------
davidm's Profile: http://www.excelforum.com/member.php...o&userid=20645
View this thread: http://www.excelforum.com/showthread...hreadid=526630


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Need Code to rename standard modules


Many thanks Greg. For some reason, that code has never worked for me,
logical as it is (and with Microsoft Visual Basic for Applications
Extensibility reference enabled). I would welcome any feedback on
this.

[ps: I am sorry for the multiple postings of the initial thread. It was
due to server problems I was encountering and which made it hard to
authenticate submissions].


David


--
davidm
------------------------------------------------------------------------
davidm's Profile: http://www.excelforum.com/member.php...o&userid=20645
View this thread: http://www.excelforum.com/showthread...hreadid=526630

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 747
Default Need Code to rename standard modules

If you meant the code I gave you doesn't work for you, it may be that you
have a later version of Excel that restricts access to the VBProject. I'm
running xl2000 and don't have a problem.

Check ToolsMacroSecurity and check to see if there is a "Trust access to
VBProject" checkbox in one of the tabs. I don't have this but have seen it in
later versions. If so, make sure this checkbox is checked. Otherwise, it is
likely a security issue that I'm not up to date with.

Regards,
Greg

"davidm" wrote:


Many thanks Greg. For some reason, that code has never worked for me,
logical as it is (and with Microsoft Visual Basic for Applications
Extensibility reference enabled). I would welcome any feedback on
this.

[ps: I am sorry for the multiple postings of the initial thread. It was
due to server problems I was encountering and which made it hard to
authenticate submissions].


David


--
davidm
------------------------------------------------------------------------
davidm's Profile: http://www.excelforum.com/member.php...o&userid=20645
View this thread: http://www.excelforum.com/showthread...hreadid=526630


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Need Code to rename standard modules

David,

Try

ThisWorkbook.VBProject.VBComponents("Sheet1").Name = "NewName"

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"davidm"
wrote in message
...

Can someone kindly help me out with a code to *rename* standard
modules?
I have googled in vain for leads. Even Chip Pearson seemed to
have miss
this one in his comprehensive coverage of codings to manipulate
VBComponents.

[I intend using the first 8 or so characters of ProcedureTitles
to
rename meaningfully and can quite comfortably handle this bit
of
extracting the characters].

TIA

David


--
davidm
------------------------------------------------------------------------
davidm's Profile:
http://www.excelforum.com/member.php...o&userid=20645
View this thread:
http://www.excelforum.com/showthread...hreadid=526630





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Need Code to rename standard modules

Even Chip Pearson seemed to have miss
this one in his comprehensive coverage of codings to manipulate
VBComponents.


Actually, the info is hidden on the CodeMods page,
http://www.cpearson.com/excel/codemods.htm . I'll add it to the
VBE page.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com





"davidm"
wrote in message
...

Can someone kindly help me out with a code to *rename* standard
modules?
I have googled in vain for leads. Even Chip Pearson seemed to
have miss
this one in his comprehensive coverage of codings to manipulate
VBComponents.

[I intend using the first 8 or so characters of ProcedureTitles
to
rename meaningfully and can quite comfortably handle this bit
of
extracting the characters].

TIA

David


--
davidm
------------------------------------------------------------------------
davidm's Profile:
http://www.excelforum.com/member.php...o&userid=20645
View this thread:
http://www.excelforum.com/showthread...hreadid=526630



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
Need Code to rename standard modules davidm Excel Programming 0 March 27th 06 04:26 AM
How can we rename modules? StargateFanFromWork[_3_] Excel Programming 4 January 26th 06 07:41 PM
Rename Modules Ian Excel Programming 6 March 29th 05 02:29 PM
Standard Modules in VBA Standard Modules in VBA Excel Programming 1 March 15th 05 03:33 AM
When to code in sheet or userform modules and when to use modules Tony James Excel Programming 1 December 16th 04 10:02 PM


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