+ Reply to Thread
Results 1 to 3 of 3

addin and main menu disappears

  1. #1
    Przemek
    Guest

    addin and main menu disappears

    Hi, I've created addin with small toolbar and additional subs connected
    to buttons. But when I'm opening Excel (2003) and my addin is loaded,
    main menu ( File, Edit etc.) is disappearing How can i resolve that
    problem?

    Here is my code for my toolbar in ThisWorkbook:

    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    DeleteCommandbar
    End Sub
    Private Sub Workbook_Open()
    CreateCommandbar
    End Sub
    Sub CreateCommandbar()
    Const CStCmdBar As String = "Platnosci"
    Call DeleteCommandbar
    With Application.CommandBars.Add(CStCmdBar, msoBarFloating, True, True)
    ..Visible = True
    ..Position = msoBarTop
    ..RowIndex = Application.CommandBars("Formatting").RowIndex
    ..Protection = msoBarNoChangeVisible + msoBarNoCustomize + msoBarNoMove
    With .Controls
    With .Add(msoControlButton) ' first button
    ..Style = msoButtonIcon
    ..FaceId = 107
    ..OnAction = "ThisWorkbook.Listaplat"
    ..TooltipText = "Lista platnosci"
    End With
    With .Add(msoControlButton) 'second button
    ..Style = msoButtonIcon
    ..FaceId = 144
    ..TooltipText = "Platnosci"
    ..OnAction = "ThisWorkbook.Platnosci"
    End With
    End With
    End With
    Application.CommandBars("Worksheet Menu Bar").Enabled = True
    End Sub
    Sub DeleteCommandbar()
    On Error Resume Next
    CommandBars("Platnosci").Delete
    End Sub

    Przemek


  2. #2
    keepITcool
    Guest

    Re: addin and main menu disappears

    change the 3rd argument of the commandbars.add to false
    (you want a "toolbar" not a "menubar"

    also note that the deletebar works better
    when you precide it with application.


    Option Explicit

    Private Const CStCmdBar As String = "Platnosci"

    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    DeleteCommandbar
    End Sub
    Private Sub Workbook_Open()
    CreateCommandbar
    End Sub

    Sub CreateCommandbar()
    Call DeleteCommandbar
    With Application.CommandBars.Add(CStCmdBar, msoBarFloating, False,
    True)
    .Visible = True
    .Position = msoBarTop
    .RowIndex = Application.CommandBars("Formatting").RowIndex
    .Protection = msoBarNoChangeVisible + msoBarNoCustomize +
    msoBarNoMove
    With .Controls
    With .Add(msoControlButton) ' first button
    .Style = msoButtonIcon
    .FaceId = 107
    .OnAction = "ThisWorkbook.Listaplat"
    .TooltipText = "Lista platnosci"
    End With
    With .Add(msoControlButton) 'second button
    .Style = msoButtonIcon
    .FaceId = 144
    .TooltipText = "Platnosci"
    .OnAction = "ThisWorkbook.Platnosci"
    End With
    End With
    End With
    End Sub
    Sub DeleteCommandbar()
    On Error Resume Next
    Application.CommandBars(CStCmdBar).Delete
    End Sub




    --
    keepITcool
    | www.XLsupport.com | keepITcool chello nl | amsterdam


    Przemek wrote :

    >


  3. #3
    Przemek
    Guest

    Re: addin and main menu disappears

    Tx for help, it works!

    Przemek


+ Reply to Thread

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