combo (TechnicalUser) (OP)
15 Sep 03 5:35
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:
Attribute VB_Name = "c_name" - component name
Attribute VB_HelpID = intID - help ID
Attribute VB_Description = "description_text" - procedure description
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?