Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


VBA/VBE/Excel - enhance macros

VBA/VBE/Excel - enhance macros

VBA/VBE/Excel - enhance macros

Excel interface offers Tools>Macro>Macros dialog (options button) to add descriptions and hotkeys to subs and functions (functions cannot be selected, but are accessible after writing their names). Function description is next visible when creating function with function wizard.

VBA offers more possibilities with (some arguments are ommited):
Application.MacroOptions Macro:="macro_name", Description:="description_text", HasShortcutKey:=boolHSK, ShortcutKey:="key", HelpContextId:=intID, Category:= catID, HelpFile:="help_path&file"
"description_text" - macro description, as above,
boolHSK - True/False, indicates existence of shortcut,
"key" - a character, a hotkey with CTRL key pressed,
catID - a group of functions where "macro_name" can be found,
intID - a number to reference help entry,
"help_path&file" - a reference to help file, visible in VBA project properties.

VBE offers another way to add descriptions - Object Browser. After selecting your project and right-click one of project's classes or created member (sub, function, property), 'Properties...' is active in the popup menu. When clicked, a description and help ID can be added, the help file is the same as for the project.
The description is what you see in description section of object browser, for procedures is the same as in two above, for vb components - it is new feature.

All the above is an echo of class attributes and can be visible after exporting a component and editing it in text editor (moreover, some new features can be added), a selection:
Module level:
Attribute VB_Name = "c_name" - component name
Attribute VB_HelpID = intID  - help ID
Attribute VB_Description = "description_text" - procedure description
Procedure level:
Attribute proc.VB_UserMemId = 0 - makes property "proc" default (a blue dot in browser, VBA - the
only way to set)
Attribute proc.VB_Description = "text" - procedure description
Attribute proc.VB_HelpID = intID - again, help
Attribute proc.VB_ProcData.VB_Invoke_Func = "X\n4" - here "X" is procedure hotkey, 4 is function category
variable level (in VBA - the only way to add):
Attribute var.VB_VarHelpID = intID - help
Attribute var.VB_VarDescription = description_text" - variable description
Above statements are located at the top for module level, after declaration for procedures and variables.

As 'Attribute' is in practice undocumented in VBA, can we share our experience here?


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close