Results 1 to 10 of 10

Thread: [RESOLVED] CommandBar problem

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2005
    Posts
    44

    [RESOLVED] CommandBar problem

    I am trying to create a commandbar, but unfortunately I am getting the following error: User defined type not defined. And yes, I have set a reference to Microsoft 9.0 Object Library in the VBE. That was the first thing I checked....

    The error occurs at the first line, where I try to declare the command bar:
    VB Code:
    1. Dim cbrMenuBar As CommandBar
    2. Set cbrMenuBar = CommandBars.Add("MyBar", msoBarTop, True, True)
    3. cbrMenuBar.Visible = True

    Thanks all
    Last edited by Santos7772005; Jan 30th, 2006 at 07:35 PM. Reason: Resolved

  2. #2
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: CommandBar problem

    ?? strange. did you try removing the library? then adding it back in?
    was CommandBar an available "choice" in the intellisense dropdown?
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: CommandBar problem

    "Microsoft 9.0 Object Library"? Which program are you trying to add it to?

    Usually you add a reference to "Microsoft Excel xx.0 Object Library"
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  4. #4
    Lively Member
    Join Date
    Jan 2006
    Posts
    80

    Re: CommandBar problem

    i kept having this problem , try adding office. before the commandbar?

    worked for me, the same with outlook, i had to write outlook.application, just wouldnt work with application on its own

    jamie

  5. #5

    Thread Starter
    Member
    Join Date
    Nov 2005
    Posts
    44

    Re: CommandBar problem

    Ok, thanks for the feedback guys. No, commandbar was not a choice in the intellisense dropdown. This code is part of an export routine in Access - what I am trying to do is output a word document. My database contains test scripts that our company uses to test our products, what I am trying to do is output these test scripts to a word document as autotext entries, and then attach each one to a button on a commandbar.

  6. #6
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: CommandBar problem

    ok.. if you do not get CommandBar as an Intellisense choice then u do not have the correct refrence...

    Try adding ref to Word Object...

    Try typing Office. is office a "choice"?
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  7. #7
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: CommandBar problem

    If your writting this with Word then it will be accessible from...
    VB Code:
    1. Application.CommandBars
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  8. #8

    Thread Starter
    Member
    Join Date
    Nov 2005
    Posts
    44

    Re: CommandBar problem

    After doing a bit more investigation I have found that the code I originally posted works fine if it is in a word document, so my problem is with Access. Is there any way to write out a word document from access and create the toolbar at the same time? If not I guess I will just have to write this code in word and have it get the data from access, I was really hoping to have it the other way round... in any case thanks for your help guys

  9. #9
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: CommandBar problem

    Did you add a reference to Word and Office in Access' VBA IDE?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  10. #10

    Thread Starter
    Member
    Join Date
    Nov 2005
    Posts
    44

    Re: CommandBar problem

    Did you add a reference to Word and Office in Access' VBA IDE?

    Ok, thanks, thats the problem! I only had a reference to word - I did not have a reference to the Office objects library.

Posting Permissions

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



Click Here to Expand Forum to Full Width