• Excel menus and toolbars (VB6/.NET)

    Author
    Topic
    #404043

    I’m writing an application (I’m actually writing it in VB.NET but I have the same problem in VB6 and this forum seems larger than the .NET forum), that interrogates several tables in a database allowing a user to select a variety of criteria and eventually create an Excel workbook using automation for which I’m using the MS Excel 11.0 Object Library.

    After the user is prompted to save the workbook, I want to give them the option to leave it open so they can fiddle about with it. Unfortunately the resulting Excel instance is lacking menus and toolbars and I can’t for the life of me find a way to get them to display.

    Does anyone know how to get menus and toolbars to display in an instance of Excel instantiated from VB?

    As usual all help will result in gratuitous platitudes.

    Regards,
    Kevin Bell

    Viewing 1 reply thread
    Author
    Replies
    • #819036

      This line should show the worksheet menubar:
      Oddly enough the visible property doesn’t seem to work for the main worksheet menubar.

      Dim xlApp as Excel.Application
      xlApp.Commandbars(1).Enabled=True

      You could also refer to a bar by name, this shows the standard toolbar:

      Application.CommandBars(“Standard”).Visible = True

      The names of all commandbars are available through my xlmenufundict, downloadable from my site below.

      • #819524

        Thanks for the reply Jan.

        I tried your suggestion and it made no difference I’m afraid.

        I added a reference to the MS Excel 11.0 Object Library and then I added the code below to the Click event of a form.

        Dim xl As New Excel.Application

        xl.WindowState = xlMinimized
        xl.ScreenUpdating = True
        xl.Workbooks.Add
        xl.CommandBars(“Standard”).Enabled = True
        xl.CommandBars(“Standard”).Visible = True

        When I click the form, Excel appears but still no menus or toolbars.

        I’ll keep on trying.

        Regards,
        Kevin Bell

        • #819529

          had a quick play with your code and found the same effect. Adding the line “xl.Visible = True” made it behave correctlty.

          StuartR

        • #819530

          had a quick play with your code and found the same effect. Adding the line “xl.Visible = True” made it behave correctlty.

          StuartR

      • #819525

        Thanks for the reply Jan.

        I tried your suggestion and it made no difference I’m afraid.

        I added a reference to the MS Excel 11.0 Object Library and then I added the code below to the Click event of a form.

        Dim xl As New Excel.Application

        xl.WindowState = xlMinimized
        xl.ScreenUpdating = True
        xl.Workbooks.Add
        xl.CommandBars(“Standard”).Enabled = True
        xl.CommandBars(“Standard”).Visible = True

        When I click the form, Excel appears but still no menus or toolbars.

        I’ll keep on trying.

        Regards,
        Kevin Bell

    • #819037

      This line should show the worksheet menubar:
      Oddly enough the visible property doesn’t seem to work for the main worksheet menubar.

      Dim xlApp as Excel.Application
      xlApp.Commandbars(1).Enabled=True

      You could also refer to a bar by name, this shows the standard toolbar:

      Application.CommandBars(“Standard”).Visible = True

      The names of all commandbars are available through my xlmenufundict, downloadable from my site below.

    Viewing 1 reply thread
    Reply To: Excel menus and toolbars (VB6/.NET)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: