Results 1 to 10 of 10

Thread: Run-Time Error '5': Invalid procedure call or argument

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    The script above is inserted inside the sheet, while this is locatedd in ThisWorkbook

    Option Explicit
    Private Sub Workbook_Open()
        ' Check to see if to toolbars exist, if they do display the appropriate one for the sheet
        Dim sCommandBar As CommandBar
        Dim iCommandBarCount As Integer
        For Each sCommandBar In Application.CommandBars
            If (sCommandBar.Name = sToolBarTemplateActions) Or (sCommandBar.Name = sToolBarDataInputActions) Or _
                (sCommandBar.Name = sToolBarStagingAndSubmissionActions) Then
                iCommandBarCount = iCommandBarCount + 1
                Call recreateToolBar(sCommandBar.Name)
            End If
        Next sCommandBar
    ' If the commandbars don't exist then create them
        If iCommandBarCount = 0 Then
        Call createToolBar(sToolBarTemplateActions)
        Call createToolBar(sToolBarDataInputActions)
        Call createToolBar(sToolBarStagingAndSubmissionActions)
        End If
    ' Activate the appropriate toolbar
        Select Case ActiveSheet.Name
        Case sSheet3
            Application.CommandBars(sToolBarTemplateActions).Visible = True
        Case sSheet4
            Application.CommandBars(sToolBarDataInputActions).Visible = True
        Case sSheet5
            Application.CommandBars(sToolBarStagingAndSubmissionActions).Visible = True
        End Select
        ' Initialize btnProtocol
        Sheets(sSheet2).btnProtocol.Clear
        Sheets(sSheet2).btnProtocol.AddItem ("http")
        Sheets(sSheet2).btnProtocol.AddItem ("https")
        If Sheets(sSheet2).Range("rngProtocol").Value <> "" Then
        Sheets(sSheet2).btnProtocol.Value = Sheets(sSheet2).Range("rngProtocol").Value
        Sheets(sSheet2).Range("rngProtocol").Value = ""
        End If
    ' Populate the Action button
        Sheets(sSheet2).btnAction.Clear
        If Sheets(sSheet2).Range("rngAction").Value = "CREATE" Then
        Sheets(sSheet2).btnAction.AddItem ("CREATE")
        End If
        Sheets(sSheet2).btnAction.AddItem ("UPDATE")
        Sheets(sSheet2).btnAction.AddItem ("UPDATEDATA")
    End Sub
    
    
    Private Sub Workbook_BeforeClose(Cancel As Boolean)
        ' Close down the toolbars on exit
        Application.CommandBars(sToolBarTemplateActions).Visible = False
        Application.CommandBars(sToolBarDataInputActions).Visible = False
        Application.CommandBars(sToolBarStagingAndSubmissionActions).Visible = False
    End Sub
    Last edited by Aussiebear; 06-26-2025 at 11:39 AM.

Posting Permissions

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