Results 1 to 4 of 4
  1. #1
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Naming Template Projects & Modfules (Word 2000/SR-1)

    Hi:

    I'm about to redo both my macros.dot & save as much as I can. Almost all my macros are in one Project called TemplateProject & the module called NewMacros.

    What I intend to do is divide my macros among different modules.

    One of my goals is this. Whenever I click Tools/Customize/Macros (under catagories), I cannot read most of my macros because the dialog box is taken up by the icon & the words "TemplateProject.NewMacros".

    1. What is the best way to achive this goal?
    2. What is the best way to rename the project & modules, or is there a better way?

    My gut reaction would be to rename TemplateProject to, say, "TP" or something similar & give the modules short names.

    Thanks in advance.

  2. #2
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Naming Template Projects & Modfules (Word 2000/SR-1)

    Hi Phil,

    1. The goal is not completely achievable, due to the poor design of that dialog box - the limited number of characters it displays is a major pain in the ass. So even if you give the project and modules shorter names, if they are going to be meaningful names, they're still likely to be too long to display properly in that dialog (or, the project and module names will fit in the dialog, but the actual procedure names won't!).

    2. You might consider using prefixes before the project and module names i.e. "prjMacros" and "modFindReplProcs" - much the same as prefixes are used for variables - so you always know what type of object the name refers to. Group the macros in modules by related function, and give the modules names that reflect that function.

    Since the full project/module/procedure name probably isn't going to fit in that dialog anyway, might as well give them all meaningful names as it makes everything easier to keep track of.

    Gary

  3. #3
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Naming Template Projects & Modfules (Word 2000/SR-1)

    Hi Gary:
    Thanks for the advice. It's going to be quite a project for me, as I can only squeeze it in for a short time during the evening. Three more questions, please.

    1. If I copy the text of several macros in a row, can I just paste them in the right side (code side) of a new module of a new template of the VBE & have them automatically appear with correct names when I press Alt+F8 in Word? i.e. can I create a bunch of macros at one time or just 1 at a time (they are now in a single module)?

    2. Is it possible to set "require variable declarations" for some macros, but not others? i.e. does that option work per module or per macro?

    3. One of my macros gives a error message when I have "Option Explicit" set. The variable is
    BQuotes$ = Chr$(147)

    When I write
    DIM BQuotes$ As anything, I get another error message saying "expected end of statement". I've tried to define it as a string & that doesn't work. How do I define this?

    Thanks again,

  4. #4
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Naming Template Projects & Modfules (Word 2000/SR-1)

    Hi Phil,

    1. Yes, you should be able to paste them into a new module, and they will automatically appear in the macros dialog next time you press Alt+F8. If however, you leave the original ones in the original module as well, then the macros dialog will show both sets of identical macro names, qualified by the name of the module they're in i.e. "modUtilities.FindReplace" and "Module1.FindReplace" - the point being it's best not to have two macros with the same name, in the same template.

    2. "Require variable declarations" is done by using the "Option Explicit" declaration at the beginning of the module, and this is a module-level rather than procedure-level declaration. So you would need two separate modules in this case.

    3. There are a number of symbols that are used as shortcuts for declaring variable types, and "$" is one of them. I came along too late to use these so don't know much by way of detail, but presumably these were how variable types were declared in some earlier languages. They can still be used in VBA, but general consensus of what I've read is to avoid their use. Anyway it seems like as soon as you use that "$" in a "Dim" statement, VBA already knows you're declaring a variable of type string.

    The following little test seems to confirm that:

    Sub TestingForStringType()
    Dim strName$
    MsgBox VarType(strName$) 'returns 8, which = vbString
    End Sub

    (According to the Help documentation, the VarType function is used for determining the subtype of variables that are variants. But it looks like it works for typed variables as well. For more details on the various constants, see the Help topic for VarType Function.)

    Good luck with your project!

    Gary

Posting Permissions

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