View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
Jacob Skaria Jacob Skaria is offline
external usenet poster
 
Posts: 8,520
Default Run-time error '5': Invalid procdre call or argumnt - End/Debu

--To handle the error add one more line in Private Sub Workbook_BeforeClose
as below...

--Mean while is there a additional button getting added under the Tools menu
named 'Custom Delimited File'


Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error Resume Next

' remove item from menu
Application.CommandBars("Worksheet Menu
Bar").Controls("&Tools").Controls("Custom Delimited File") _
.Delete
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"akm" wrote:

Joel
Thank you for the reply!
The code is as follows...

Option Explicit

Private Sub Workbook_BeforeClose(Cancel As Boolean)

' remove item from menu
Application.CommandBars("Worksheet Menu
Bar").Controls("&Tools").Controls("Custom Delimited File") _
.Delete

End Sub

Private Sub Workbook_Open()

Dim cb As CommandBar
Dim cbp As CommandBarPopup
Dim cbb As CommandBarButton

' add button under Tools to the Excel menu to execute the add-in

Set cb = Application.CommandBars("Worksheet Menu Bar")
Set cbp = cb.Controls("&Tools")
Set cbb = cbp.Controls.Add(Type:=msoControlButton, Temporary:=True)
With cbb
.Caption = "Custom Delimited File"
.BeginGroup = True
.OnAction = "MakeFile"
On Error Resume Next
.FaceId = 3272
On Error GoTo 0
End With

Set cbp = Nothing
Set cbb = Nothing
Set cb = Nothing

End Sub

--
Thanks again for your help.
OS: XP, SP-2 (Office2003)



"Joel" wrote:

the is a macro whih gets executed automatically when you close the workbook.
If you press debug you will see the macro. You can copy and post the code if
you want help getting rid of the error.

Yo can also delete the macro if you want.

"akm" wrote:

When exit Excel, get 'Microsoft Visual Basic' pop-up error message ...
"Run-time error '5': Invalid procedure call or argument", with buttons 'End',
'Debug', and 'Help' to click.

When click 'End', the program ends and all seems ok.

Why does it need to go thru this process, and is there a problem that we are
missing ?

--
Thanks again for your help.
OS: XP, SP-2 (Office2003)