Consulting

Results 1 to 1 of 1

Thread: Error message Type mismatch

  1. #1
    VBAX Newbie
    Joined
    Jul 2018
    Posts
    1
    Location

    Error message Type mismatch

    Option Explicit
    
    Sub Aacro1()
        Dim ToolsMenu As CommandBarPopup
        Dim NewMenuItem As CommandBarButton
        MsgBox VarType(ToolsMenu)
        MsgBox VarType(Application.CommandBars("Worksheet Menu Bar").Controls("Tools"))
        Set ToolsMenu = Application.CommandBars("Worksheet Menu Bar").Controls("Tools")
        Set NewMenuItem = ToolsMenu.Controls("New Command")
        Set NewMenuItem = ToolsMenu.Controls.Add(Type:=msoControlButton)
        NewMenuItem.Caption = "New Command"
        NewMenuItem.OnAction = "SayHello"
    End Sub
    
    Sub SayHello()
       MsgBox "Hello"
    End Sub
    Last edited by Aussiebear; 10-24-2024 at 12:56 PM.

Tags for this Thread

Posting Permissions

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