Results 1 to 3 of 3
  1. #1
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Naming a module (VBA/Word/2003)

    While the following code will create a module for me, I am unable to control the newly created module's name.

    Can anyone tell me how to accomplish this?

    Is it possible to rename a module using code?
    <pre>Public Sub Main()
    With ThisDocument.VBProject
    .VBComponents.Add vbext_ct_StdModule
    End With
    End Sub
    </pre>

    Regards
    Don

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Naming a module (VBA/Word/2003)

    Like this:

    Dim vbc As VBComponent
    Set vbc = ThisDocument.VBProject.VBComponents.Add(vbext_ct_S tdModule)
    vbc.Name = "basTest"

  3. #3
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Naming a module (VBA/Word/2003)

    Thank you Hans

    I keep forgetting the power of using this type of construct. With your guidance; renaming a module was a snap.
    Regards
    Don

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •