+ Reply to Thread
Results 1 to 5 of 5

command bar throwing run-time5

  1. #1
    Forum Contributor
    Join Date
    12-16-2016
    Location
    Colorado, US
    MS-Off Ver
    2013
    Posts
    115

    command bar throwing run-time5

    Good Morning Everyone,

    I'm missing something very simple here I think, I'm pretty sure on the launch this is calling for the program to make the toolbar again which is giving me the error. here is the code I am working with, if anyone knows how to get around this error please let me know.

    "

    Sub Auto_Open()
    Dim My_Menu As CommandBar, newControl, newItem, subMenu


    Set My_Menu = CommandBars.Add(Name:="Oncore Modifications", Position:=msoBarTop, MenuBar:=False)
    My_Menu.Visible = True
    Set newControl = My_Menu.Controls.Add(Type:=msoControlPopup)
    newControl.Caption = "Oncore Modifications"
    With newControl
    Set subMenu = .Controls.Add(Type:=msoControlPopup)
    End With
    With subMenu
    .Caption = "Trim Spaces Functions"
    Set newItem = .Controls.Add(Type:=msoControlButton)
    newItem.Caption = "Trim Left"
    newItem.OnAction = "TrimL"
    Set newItem = .Controls.Add(Type:=msoControlButton)
    newItem.Caption = "Trim Right"
    newItem.OnAction = "TrimR"
    Set newItem = .Controls.Add(Type:=msoControlButton)
    newItem.Caption = "Trim Left and Right"
    newItem.OnAction = "TrimLR"
    Set newItem = .Controls.Add(Type:=msoControlButton)
    newItem.Caption = "Trim Irregular Spacing"
    newItem.OnAction = "TrimIrregular"
    Set newItem = .Controls.Add(Type:=msoControlButton)
    newItem.Caption = "Trim All"
    newItem.OnAction = "RemoveAllSpaces"
    End With
    With newControl
    Set subMenu = .Controls.Add(Type:=msoControlPopup)
    End With
    With subMenu
    .Caption = "Report Format Options"
    Set newItem = .Controls.Add(Type:=msoControlButton)
    newItem.Caption = "CF Backlog"
    newItem.OnAction = "ONCORE_CA_BACKLOG"
    Set newItem = .Controls.Add(Type:=msoControlButton)
    newItem.Caption = "Oncore OOR"
    newItem.OnAction = "Oncore_OOR"
    Set newItem = .Controls.Add(Type:=msoControlButton)
    newItem.Caption = "Send to Michelle"
    newItem.OnAction = "Send_to_Michelle"
    End With

    End Sub


    Im pretty sure, I just need to add a line telling the program to not try to load it again once the add-in is launched but I am drawing a blank

    Any help from those greater and wiser than myself is always appreciated.

    Fawkes_

  2. #2
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: command bar throwing run-time5

    When creating command bars, I
    1) Always set the Temporary argument to True. I don't like leaving command bars behind in the user's Excel.

    2) Always delete the command bar "myBar" before creating a command bar "myBar". Buffering with On Error Resume Next.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  3. #3
    Forum Contributor
    Join Date
    12-16-2016
    Location
    Colorado, US
    MS-Off Ver
    2013
    Posts
    115

    Re: command bar throwing run-time5

    Would this work for the issue?

    Commandbars("oncore modifications").delete
    on error resume next
    Set My_Menu = CommandBars.Add(Name:="Oncore Modifications", Position:=msoBarTop, MenuBar:=True)
    My_Menu.Visible = True

  4. #4
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: command bar throwing run-time5

    Quote Originally Posted by Fawkes_ View Post
    Would this work for the issue?
    1) You need to use code tags when posting code. (see my sig)

    2) What happened when you tried it?

  5. #5
    Forum Contributor
    Join Date
    12-16-2016
    Location
    Colorado, US
    MS-Off Ver
    2013
    Posts
    115

    Re: command bar throwing run-time5

    Thank you for your assistance, have a nice day

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Vlookup throwing off #N/A
    By forestavekids in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 12-21-2016, 06:19 PM
  2. [SOLVED] VBA code throwing error
    By philozelda in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-17-2015, 02:35 PM
  3. [SOLVED] Split VBA throwing an error
    By GreenTee in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-03-2015, 05:34 PM
  4. [SOLVED] This Code Is Throwing An Error At The End...
    By Regular_Joe in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-03-2014, 11:15 AM
  5. VLOOKUP throwing #N/A Error
    By duger99 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-31-2014, 09:38 AM
  6. [SOLVED] Sumproduct throwing value error
    By LeapingLizard in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-08-2012, 05:33 PM
  7. Throwing an error ... on purpose!
    By Sarah B via OfficeKB.com in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-20-2005, 04:05 PM

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