Macro Naming Conventions

B

Bob Weaver

What are the general naming conventions for Macros in Word
2002? Specifically, prohibited characters and length of
the macro name.

Thanks,
 
C

Chad DeMeyer

"Use the following rules when you name procedures, constants, variables, and arguments in a Visual Basic module:
a.. You must use a letter as the first character.
b.. You can't use a space, period (.), exclamation mark (!), or the characters @, &, $, # in the name.
c.. Name can't exceed 255 characters in length.
d.. Generally, you shouldn't use any names that are the same as the functions, statements, and methods in Visual Basic. You end up shadowing the same keywords in the language. To use an intrinsic language function, statement, or method that conflicts with an assigned name, you must explicitly identify it. Precede the intrinsic function, statement, or method name with the name of the associated type library. For example, if you have a variable called Left, you can only invoke the Left function using VBA.Left.
e.. You can't repeat names within the same level of scope. For example, you can't declare two variables named age within the same procedure. However, you can declare a private variable named age and a procedure-level variable named age within the same module.
Note: Visual Basic isn't case-sensitive, but it preserves the capitalization in the statement where the name is declared."
-Word 2000 VBA Help

Regards,
Chad
 
J

Jay Freedman

Bob said:
What are the general naming conventions for Macros in Word
2002? Specifically, prohibited characters and length of
the macro name.

Thanks,

Hi Bob,

According to
http://office.microsoft.com/assista...ID=HP051867721033&CTT=4&Origin=CH063666331033,
procedure names can be up to 255 letters, numbers, or underscores, subject
to a few other rules.

This conflicts a bit with http://support.microsoft.com/?kbid=211489, which
says the maximum is 80 characters. You're welcome to experiment and report
back. :)
 
G

Guest

Chad:

Thanks for the info! I was trying to use an underscore to
keep a group of names together... I know better now!

Bob Weaver
-----Original Message-----
"Use the following rules when you name procedures,
constants, variables, and arguments in a Visual Basic
module:
a.. You must use a letter as the first character.
b.. You can't use a space, period (.), exclamation mark
(!), or the characters @, &, $, # in the name.
c.. Name can't exceed 255 characters in length.
d.. Generally, you shouldn't use any names that are the
same as the functions, statements, and methods in Visual
Basic. You end up shadowing the same keywords in the
language. To use an intrinsic language function,
statement, or method that conflicts with an assigned name,
you must explicitly identify it. Precede the intrinsic
function, statement, or method name with the name of the
associated type library. For example, if you have a
variable called Left, you can only invoke the Left
function using VBA.Left.
e.. You can't repeat names within the same level of
scope. For example, you can't declare two variables named
age within the same procedure. However, you can declare a
private variable named age and a procedure-level variable
named age within the same module.
Note: Visual Basic isn't case-sensitive, but it
preserves the capitalization in the statement where the
name is declared."
-Word 2000 VBA Help

Regards,
Chad



"Bob Weaver" <[email protected]> wrote
in message news:[email protected]...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top