Results 1 to 5 of 5
  1. #1
    3 Star Lounger
    Join Date
    Aug 2001
    Location
    Jeddah, Saudi Arabia
    Posts
    243
    Thanks
    0
    Thanked 1 Time in 1 Post

    Excel menus and toolbars (VB6/.NET)

    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

  2. #2
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Excel menus and toolbars (VB6/.NET)

    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.
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

  3. #3
    3 Star Lounger
    Join Date
    Aug 2001
    Location
    Jeddah, Saudi Arabia
    Posts
    243
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Excel menus and toolbars (VB6/.NET)

    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

  4. #4
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Excel menus and toolbars (VB6/.NET)

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

    StuartR

  5. #5
    3 Star Lounger
    Join Date
    Aug 2001
    Location
    Jeddah, Saudi Arabia
    Posts
    243
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Excel menus and toolbars (VB6/.NET)

    Perfect Stuart. Thanks.

    Regards,
    Kevin Bell

Posting Permissions

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