Results 1 to 6 of 6

Invalid procedure call (CommandBars)

Threaded View

Rick_Stanich Invalid procedure call... 11-13-2009, 09:25 AM
Andy Pope Re: Invalid procedure call... 11-13-2009, 09:40 AM
Rick_Stanich Re: Invalid procedure call... 11-13-2009, 10:52 AM
Andy Pope Re: Invalid procedure call... 11-13-2009, 11:00 AM
Rick_Stanich Re: Invalid procedure call... 11-13-2009, 11:02 AM
Andy Pope Re: Invalid procedure call... 11-13-2009, 11:06 AM
  1. #1
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,179

    Invalid procedure call (CommandBars)

    I create and load a commandbar, prior to loading it I attempt to check if it exists, then delete it, and recreate.
    I dont understand why this seemed to work for months and now creates an error.
    It appears that every now and then the created commandbar is not created when I open a file. Thats when the error pops up. I can manually run the Create_Bar sub and it will be fine, for a while.

    Run-time error '5':
    Invalid procedure call or argument
    This section is in my personal.xls file in "ThisWorkBook" of personal.xls.
    'Add to "ThisWorkBook" in Personal.xls or other excel file
    '===============================
    Option Explicit
    
    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    Call AddToolBar.Delete_Bar
    End Sub
    
    Private Sub Workbook_Open()
    Call AddToolBar.Create_Bar
    End Sub
    '===============================
    This section is a module (AddToolBar) in personal.xls
    Option Explicit
    
    Sub Create_Bar()
    Dim MyBar As CommandBar
    Dim MyPopup As CommandBarPopup
    Dim MyButton As CommandBarButton
    
    On Error Resume Next '10.30.09
    
    Set MyBar = CommandBars.Add(Name:="Custom Menu", _
            Position:=msoBarTop, temporary:=True)
    'Create commnadbar here
              'code removed to save space
    End Sub
    
    Sub Delete_Bar()
    Dim cbExists As Boolean
    cbExists = False
    On Error Resume Next
    cbExists = Application.CommandBars("Custom Bar").Name = "Custom Menu"
    On Error GoTo 0
    If cbExists Then
        CommandBars("Custom Menu").Delete
    Else
    End If
    End Sub
    Code in red is where the error occurrs.

    p.s.
    This has been happening before today, Friday the 13th, so I dont think its that.
    Last edited by Rick_Stanich; 11-13-2009 at 11:02 AM.
    Regards

    Rick
    Win10, Office 365

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1