ACC97: Error Creating CommandBar with Duplicate Name
ID: Q162822
|
The information in this article applies to:
SYMPTOMS
Advanced: Requires expert coding, interoperability, and multi-user skills.
If you try to create a command bar with an existing name by using Visual
Basic for Applications, you may receive the following error message:
Run-time error '5':
Invalid procedure call or argument
If you try to create a command bar with an existing name by using the user
interface, you may receive the following error message:
A toolbar named '<name>' already exists. Type another name.
RESOLUTION
You cannot create multiple command bars with the same name in any Microsoft
Office 97 file, except in Microsoft Word 97.
STATUS
This behavior is by design.
MORE INFORMATION
The following table demonstrates how the Microsoft Office 97 applications
behave when creating duplicate command bar names:
Application Using Code Using the User Interface
-----------------------------------------------------------------
Microsoft Word 97 Yes No
Microsoft Excel 97 No No
Microsoft Access 97 No No
Microsoft Powerpoint 97 No No
NOTE: Microsoft Word 97 is able to create multiple command bars with the
same name through Visual Basic for Applications because Word needs to be
able to have multiple command bars with the same name to handle the case
where you have two templates open.
Steps to Reproduce Behavior by Using Visual Basic for Applications
- Open the sample database Northwind.mdb.
- Create a module and type the following line in the Declarations
section if it is not already there:
Option Explicit
- Type the following procedure:
Function CreateCmdBar()
Dim cb As CommandBar
Set cb = Application.CommandBars.Add("Test1")
Set cb = Application.CommandBars.Add("Test1")
End Function
- To test this function, type the following line in the Debug window,
and then press ENTER:
?CreateCmdBar()
Note that you receive the following error message on the third line
of code:
Run-time error '5':
Invalid procedure call or argument"
Steps to Reproduce Behavior by Using the User Interface
- Open the sample database Northwind.mdb.
- On the View menu, point to Toolbars, and then click Customize.
- Click the New button in the Customize dialog box. Set the Toolbar name
to Test2, and then click OK.
- Repeat step 3. Note that you receive the following error message:
A toolbar named 'Test2' already exists. Type another name.
REFERENCES
For more information about creating command bars through code, search the
Help Index for "Add Method, command bars," and then "Add Method,
(CommandBars Collection)."
For more information about creating command bars through the user
interface, ask the Microsoft Office 97 Office Assistant, "How do I
create a command bar."
Additional query words:
menubar toolbar menu shortcut xl excel access word powerpoint
Keywords : kberrmsg kbui GnlOthr UifMenub
Version : 97
Platform : WINDOWS
Issue type : kbprb