Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trouble with Event Procedure

Status
Not open for further replies.

Dan15

Technical User
Dec 23, 2002
66
US
I am trying to open and close some custom menus - when I run the following, I get the error message below:

Private Sub Workbook_BeforeClose()
Application.Toolbar("Test").Delete
End Sub

Compile Error:

Procedure Delcaration does not match description of event or procedure having the same name

What does this mean?

Thanks-
-Dan
 
Generally means you have 2 subs of the same name in the same module. Check your "Thisworkbook" module for all the subs in there. There's probably an empty Before_Close sub lying around. Just delete the text of the empty one and you should be fine Rgds
Geoff
"Some cause happiness wherever they go; others whenever they go."
-Oscar Wilde
 
It means you fiddled a part of the code you shouldn't have.

The format for workbook close event handler is
Code:
  Private Sub Workbook_BeforeClose(Cancel As Boolean)

  End Sub
Somewhere along the line you erased the parameter. You must leave it there. But you don't have to use it.

 
OK, now it doesn't like the line telling the toolbar to close. What is the correct coding? I would like to open 4 different custom menus at when the workbook is opened, then close them with the workbook.
 
I don't understand - making Toolbar plural doesn't seem to change anything
 
OK, but what is the actual code please?

Thanks-
 
Application.Commandbars("Test").Delete

that assumes, of course, that you have a commandbar named "Test", otherwise you'll get an index out of range error. If you're not sure the toolbar will always be there, you can put
on error resume next
right before the delete statement to avoid the error message.

Rob
[flowerface]
 
Sorry, I was actually looking to just open and close the toolbar -
Application.CommandBars("Test").Visible = True

Easy enough, thank you for the help anyway-

-Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top