Page 1 of 2 12 LastLast
Results 1 to 40 of 48

Thread: CommandBars doesn't support property or method

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    24

    Unhappy CommandBars doesn't support property or method

    I'm trying desperately to get a COM add-in to work with Outlook. I'm brand new at this and probably doing something fundamentally wrong.

    Using VB6 I create a new Add-in. I change absolutely nothing in the code. I use the Add-In Designer and change it to an Outlook 9 add-in and load on startup. Then create the DLL. So far so good.

    When I open Outlook 2000, however, it attempts to connect but gets an error 438, "Object doesn't support this property or method" on the line that attempts to get a reference to the CommandBars object.

    Set cbrMenu = gobjAppInstance.CommandBars(CBR_NAME)

    It never gets the reference and, of course, never creates the button. Should this work? Do I need to do something else before it can reference CommandBars?

    I have been fighting with this to the brink of madness. I would be very grateful if someone can help me out.

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

    Re: CommandBars doesn't support property or method

    Welcome to the Forums.

    Moved from COM and ActiveX forum.
    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

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

    Re: CommandBars doesn't support property or method

    Can you post more of your code like the OnConnection procedure? What is the value for CBR_NAME? Does this menu or toolbar exist yet?

    Are you running service pack 3 for Office 2000?
    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

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    24

    Re: CommandBars doesn't support property or method

    The code is exactly as it comes from the Office 2000 Developer sample. (I'll post it below).

    CBR_NAME is set to "Tools"

    And, yes, I am using SP3

    VB Code:
    1. ' ------------------------------------------
    2. ' This is the shared code module --- Randy
    3. ' ------------------------------------------
    4.  
    5. Option Explicit
    6.  
    7. ' Global variable to store reference to host application.
    8. Public gobjAppInstance   As Object
    9.  
    10. ' Constants for characters surrounding ProgID.
    11. Public Const PROG_ID_START As String = "!<"
    12. Public Const PROG_ID_END As String = ">"
    13.  
    14. ' Constants for menu item in Office application.
    15. Public Const CBR_NAME       As String = "Tools"
    16. Public Const CTL_CAPTION    As String = "My &COM Add-in"
    17. Public Const CTL_KEY        As String = "MyCOMAddIn"
    18. Public Const CTL_NAME       As String = "My COM Add-in"
    19.  
    20. Sub AddInErr(errX As ErrObject)
    21.     ' Displays message box with error information.
    22.  
    23.     Dim strMsg As String
    24.    
    25.     strMsg = "An error occurred in the COM add-in named '" _
    26.         & App.Title & "'." & vbCrLf & "Error #:" & errX.Number _
    27.         & vbCrLf & errX.Description
    28.     MsgBox strMsg, , "Error!"
    29. End Sub
    30.  
    31. Function CreateAddInCommandBarButton(ByVal Application As Object, _
    32.     ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, _
    33.     ByVal AddInInst As Object) As Office.CommandBarButton
    34.    
    35.     ' This procedure assigns a reference to the Application
    36.     ' object passed to the OnConnection event to a global
    37.     ' object variable. It then creates a new command bar
    38.     ' button and returns a reference to the button to the
    39.     ' OnConnection event procedure. The advantage to
    40.     ' putting this code in a public module is that if you
    41.     ' have more than one add-in designer in the project, you can
    42.     ' call this procedure from each of them rather than
    43.     ' duplicating the code.
    44.    
    45.     Dim cbrMenu                     As Office.CommandBar
    46.     Dim ctlBtnAddIn                 As Office.CommandBarButton
    47.    
    48.     On Error GoTo CreateAddInCommandBarButton_Err
    49.    
    50.     ' Return reference to Application object and store it in public variable
    51.     ' so that other procedures in add-in can use it.
    52.     Set gobjAppInstance = Application
    53.    
    54.     ' Return reference to command bar.
    55.  ' This is the line that errors  --- Randy
    56.     Set cbrMenu = gobjAppInstance.CommandBars(CBR_NAME)
    57.    
    58.     ' Add button to call add-in from command bar, if it doesn't
    59.     ' already exist.
    60.     ' Constants are declared at module level.
    61.     ' Look for button on command bar.
    62.     Set ctlBtnAddIn = cbrMenu.FindControl(Tag:=CTL_KEY)
    63.     If ctlBtnAddIn Is Nothing Then
    64.         ' Add new button.
    65.         Set ctlBtnAddIn = cbrMenu.Controls.Add(Type:=msoControlButton, _
    66.             Parameter:=CTL_KEY)
    67.         ' Set button's Caption, Tag, Style, and OnAction properties.
    68.         With ctlBtnAddIn
    69.             .Caption = CTL_CAPTION
    70.             .Tag = CTL_KEY
    71.             .Style = msoButtonCaption
    72.             ' Use AddInInst argument to return reference
    73.             ' to this add-in.
    74.             .OnAction = PROG_ID_START & AddInInst.ProgId _
    75.                 & PROG_ID_END
    76.         End With
    77.     End If
    78.    
    79.     ' Return reference to new commandbar button.
    80.     Set CreateAddInCommandBarButton = ctlBtnAddIn
    81.    
    82. CreateAddInCommandBarButton_End:
    83.     Exit Function
    84.  
    85. CreateAddInCommandBarButton_Err:
    86.     ' Call generic error handler for add-in.
    87.     AddInErr Err
    88.     Resume CreateAddInCommandBarButton_End
    89. End Function
    90.  
    91. Function RemoveAddInCommandBarButton(ByVal _
    92.     RemoveMode As AddInDesignerObjects.ext_DisconnectMode)
    93.  
    94.     ' This procedure removes the command bar button for
    95.     ' the add-in if the user disconnected it.
    96.  
    97.     On Error GoTo RemoveAddInCommandBarButton_Err
    98.    
    99.     ' If user unloaded add-in, remove button. Otherwise, add-in is
    100.     ' being unloaded because application is closing; in that case,
    101.     ' leave button as is.
    102.     If RemoveMode = ext_dm_UserClosed Then
    103.         On Error Resume Next
    104.         ' Delete custom command bar button.
    105.         gobjAppInstance.CommandBars(CBR_NAME).Controls(CTL_NAME).Delete
    106.         On Error GoTo RemoveAddInCommandBarButton_Err
    107.     End If
    108.    
    109. RemoveAddInCommandBarButton_End:
    110.     Exit Function
    111.    
    112. RemoveAddInCommandBarButton_Err:
    113.     AddInErr Err
    114.     Resume RemoveAddInCommandBarButton_End
    115. End Function
    116.  
    117.  
    118. ' ------------------------------------------
    119. ' This is the code from the Designer Module --- Randy
    120. ' ------------------------------------------
    121.  
    122. Option Explicit
    123.  
    124. ' Implement extensibility library.
    125. Implements IDTExtensibility2
    126.  
    127. ' Private module-level variables.
    128. Private WithEvents p_mctlBtnEvents    As Office.CommandBarButton
    129. Private p_frmCOMAddIn                 As frmCOMAddIn
    130.  
    131. Private Sub AddinInstance_Initialize()
    132.     ' Initialize event procedure for add-in designer class.
    133.     ' Create private instance of form, but don't show it.
    134.     ' Creating a private reference to the form and destroying
    135.     ' it when the add-in is disconnected ensures that no
    136.     ' instances of the form will be left in memory.
    137.    
    138.     Set p_frmCOMAddIn = New frmCOMAddIn
    139. End Sub
    140.  
    141. Private Sub AddinInstance_Terminate()
    142.     ' Terminate event procedure for add-in designer class.
    143.     ' Destroy private instance of form.
    144.    
    145.     Unload p_frmCOMAddIn
    146.     Set p_frmCOMAddIn = Nothing
    147. End Sub
    148.  
    149. '------------------------------------------------------
    150. ' This event occurs when the user clicks the menu
    151. ' command for the add-in in the Office application.
    152. '------------------------------------------------------
    153. Private Sub p_mctlBtnEvents_Click(ByVal Ctrl As Office.CommandBarButton, _
    154.     CancelDefault As Boolean)
    155.    
    156.     On Error GoTo Event_Err
    157.     ' Show form.
    158.     p_frmCOMAddIn.Show
    159.    
    160. Event_End:
    161.     Exit Sub
    162.    
    163. Event_Err:
    164.     AddInErr Err
    165.     Resume Event_End
    166. End Sub
    167.  
    168. Private Sub IDTExtensibility2_OnBeginShutdown(custom() As Variant)
    169.     ' Debug.Print OnBeginShutdown
    170. End Sub
    171.  
    172. '------------------------------------------------------
    173. ' Runs when add-in loads in Office application
    174. ' Can run when user loads add-in from Office COM Add-Ins dialog box,
    175. ' on startup, or when another application loads add-in.
    176. '------------------------------------------------------
    177. Private Sub IDTExtensibility2_OnConnection(ByVal Application As Object, _
    178.     ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, _
    179.     ByVal AddInInst As Object, custom() As Variant)
    180.    
    181.     ' Call shared code to create new command bar button
    182.     ' and return reference to it. Assign reference to
    183.     ' event-ready CommandBarButton object declared with
    184.     ' WithEvents within this module.
    185.     Set p_mctlBtnEvents = CreateAddInCommandBarButton(Application, ConnectMode, _
    186.         AddInInst)
    187.  
    188. End Sub
    189.  
    190. '-----------------------------------------------------------
    191. ' Runs when add-in is unloaded from Office application.
    192. ' Can run when user manually unloads add-in from Office
    193. ' COM Add-Ins dialog box, when application shuts down, or
    194. ' when another application unloads the add-in.
    195. '-----------------------------------------------------------
    196. Private Sub IDTExtensibility2_OnDisconnection(ByVal _
    197.     RemoveMode As AddInDesignerObjects.ext_DisconnectMode, _
    198.     custom() As Variant)
    199.  
    200.     ' Call common procedure to disconnect add-in.
    201.     RemoveAddInCommandBarButton RemoveMode
    202.  
    203. End Sub
    204.  
    205. Private Sub IDTExtensibility2_OnStartupComplete(custom() As Variant)
    206.     'Debug.Print "OnStartupComplete"
    207. End Sub
    208.  
    209. Private Sub IDTExtensibility2_OnAddInsUpdate(custom() As Variant)
    210.     'Debug.Print "OnAddInsUpdate"
    211. End Sub

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

    Re: CommandBars doesn't support property or method

    Ok, to start, your trying to set a commandbarbutton object variable to the "Tools" menu which doesnt exist. You need to drill down the menu a popup at a time. So first you want to get the menu bar reference and then find the Tools popup, etc.
    VB Code:
    1. Set cbrMenu = gobjAppInstance.CommandBars("Menu Bar")
    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

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    24

    Re: CommandBars doesn't support property or method

    Quote Originally Posted by RobDog888
    VB Code:
    1. Set cbrMenu = gobjAppInstance.CommandBars("Menu Bar")
    I changed the line to "Menu Bar", still get the same error.

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

    Re: CommandBars doesn't support property or method

    What do you get in the intellisense list for "gobjAppInstance"?
    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
    Junior Member
    Join Date
    Sep 2005
    Posts
    24

    Re: CommandBars doesn't support property or method

    Nothing. The intellisense doesn't respond at all.

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

    Re: CommandBars doesn't support property or method

    Doh!, my fault I should have seen it was declared as Object casusing it to be late bound.

    Try accessing the CommandBars off of the ActiveExplorer obejct.

    VB Code:
    1. Set cbrMenu = gobjAppInstance.ActiveExplorer.CommandBars("Menu Bar")
    I see there may also be a timing issue since your attempting to add the CB during the Startup. Outlook may not be initialized and ready for adding a CB until the OnConnectionComplete procedure, but for now lets see if we can move to the next step.
    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
    Junior Member
    Join Date
    Sep 2005
    Posts
    24

    Re: CommandBars doesn't support property or method

    Different error.

    #450

    Wrong number of arguments or invalid property assignment

    Error occurs on the same line.
    Last edited by Randy Harris; Sep 25th, 2005 at 12:29 AM. Reason: added info

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

    Re: CommandBars doesn't support property or method

    Ok, one more suggestion, change the variable from late to early bound and see what intelisense brings up.
    VB Code:
    1. Public gobjAppInstance   As Object
    2.  
    3. Public gobjAppInstance   As Outlook.Application
    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

  12. #12

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    24

    Re: CommandBars doesn't support property or method

    I think I've got a reference problem. When I tried to make the change, intellisense didn't pick up on Outlook at all. I already had a reference to MS Office 9.0 Object Library. That and the Add-In designer library are all that get added by the template. I added a reference to Microsoft Outlook 9.0 Object Library. Intellisense now picks up "gobjAppInstance.ActiveExplorer" and shows CommandBars.

    I'm sort of confused now. What references should be set? Can this even be done with late binding?

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

    Re: CommandBars doesn't support property or method

    Yes, but it takes early biinding to get it working properly and then we switch to late.

    I'll be back tomorrow but it should almost be working now. Just need to set your other object var to the menuitem.
    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

  14. #14

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    24

    Re: CommandBars doesn't support property or method

    It is very close. If I use:
    VB Code:
    1. Public gobjAppInstance As Outlook.Application
    It works perfectly. Creates the button fine, which works.

    If I use:
    VB Code:
    1. Public gobjAppInstance As Object
    I get the error: "Wrong number of arguments or invalid property assignment".

    The first form, of course, requires the Outlook library reference.

    Thank you very much for your help. I've been working on this thing for days and getting nowhere.

    Randy

  15. #15

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    24

    Re: CommandBars doesn't support property or method

    Well... It sorta works perfectly. The button is getting added to the Menu Bar on the Application window. I need to get it added to the Item (Inspector?) window so that it can act on the currently open mail message. Is it even possible to add a CommandBar button to another window that isn't open?

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

    Re: CommandBars doesn't support property or method

    Yes and No. No, you cant add a menu or toolbar button to a window that is not open/created. You can however, trap the window being created and add to it during creation.

    You will need to use the "_NewInspector(ByVal Inspector As Inspector)" event.
    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

  17. #17

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    24

    Re: CommandBars doesn't support property or method

    Sorry - I'm kinda slow.

    If this is being created in a COM add-in, how can I cause the window to be opened when the add-in is loaded?

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

    Re: CommandBars doesn't support property or method

    It wont be created until the window is created. You do know that an Inspector is a window like the new email, appointment item window, and not the main application window?
    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

  19. #19

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    24

    Re: CommandBars doesn't support property or method

    I'm just beginning to understand that.

    If I can't create a button on a Inspector window CommandBar, is there a way to call a function in a COM add-in from a macro?

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

    Re: CommandBars doesn't support property or method

    Just as you did the "Private WithEvents p_mctlBtnEvents As Office.CommandBarButton" event you can do the WithEvents for the New Inspector. In this event you will add the menu or toolbarbutton.
    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

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

    Re: CommandBars doesn't support property or method

    Something like this...
    VB Code:
    1. Public WithEvents oInsp As Outlook.Inspectors
    2.  
    3. Private Sub oInsp_NewInspector(ByVal Inspector As Inspector)
    4.     Select Case Inspector.CurrentItem.MessageClass
    5.         Case "IPM.Note"
    6.             'Add buttons relevant to email items
    7.         Case "IPM.AppointmentItem"
    8.             'Add buttons relevant to Appointment Items            
    9.     End Select
    10. End Sub
    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

  22. #22

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    24

    Re: CommandBars doesn't support property or method

    I don't understand what to do with that code. Would you know if there might be an example somewhere that I could look at?

  23. #23

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    24

    Re: CommandBars doesn't support property or method

    If the add-in is loaded when Outlook starts, a CommandBar button can be added to the Application's CommandBars at that point in time. But when Outlook starts there is no "Inspector" window open, no ActiveInspector, nor CurrentItem. How can it add a button to the Inspector window CommandBar? There doesn't seem to be any way to reference a window that isn't opened.

    I've dug through several books on Outlook and Office programming, searched the documentation and googled for hours and hours. I can't find any explanation of how to accomplish this.

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

    Re: CommandBars doesn't support property or method

    Lets take a step back for a second. Your needing to place a menu item on the man Outlook application. This will perform some action? Then when a new Inspector window is created you want to add another menu item that will perform another different action?
    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

  25. #25

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    24

    Re: CommandBars doesn't support property or method

    No, I have no need for a button on the main Outlook application. Only the read mail "Inspector" window.
    The code that I posted earlier was wrong. It put the button on the wrong CommandBar.

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

    Re: CommandBars doesn't support property or method

    Ah, I see now where we are getting mixed up. Let me see if I can set this up.

    When your OnConnection procedure runs you need to create an event for the NewInspector. Then when that event fires you will create the button and link it to your new button. Then when the buttonis clicked it will fire.

    Let me try to create an example Add-In for you. I'll be back later or tomorrow.
    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

  27. #27

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    24

    Re: CommandBars doesn't support property or method

    Well, I've made some progress. It might not be the "right" way to do it, but I was able to get the COM add-in to add the CommandBar button. I changed the code to select the mail folder and use ActiveInspector. That much works.

    I have run into another problem, just as vexing. I can add the add-in into Outlook as any user that has Administrator rights, but non privileged users can't.

    Would you have any idea what might need to be changed in the add-in to permit non aministrator users to add it to their Outlook?

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

    Re: CommandBars doesn't support property or method

    It makes entries to the registry but other then the dll file itself thats all there is depending on your addin.
    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

  29. #29

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    24

    Re: CommandBars doesn't support property or method

    I would assume that it is the registry changes that keep it from adding for non admin users. If I log in as an admin user and add the add-in it is available for that user, but not for other users. Any idea how I can get around this?

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

    Re: CommandBars doesn't support property or method

    To be sure, does your addin use any other support files that get installed to the Windows or System32 directories?
    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

  31. #31

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    24

    Re: CommandBars doesn't support property or method

    My code doesn't call anything from a support file, but I'm not sure about this AddInDesigner that is part of VB6 developer. It has a line in it that I don't understand: Implements Extensibility

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

    Re: CommandBars doesn't support property or method

    Then more then likely its a registry permissions issue. The users are not even Power Users?
    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

  33. #33

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    24

    Re: CommandBars doesn't support property or method

    No, most of the users aren't even Power Users. The Power Users and Administrators can add the add-in, but not the others. Arghh.

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

    Re: CommandBars doesn't support property or method

    You can set registry permissions for all users for just the keys needed for all user access full control using Regedit32.exe. You might give that a try.
    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

  35. #35

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    24

    Re: CommandBars doesn't support property or method

    How about that "Implements Extensibility"? Can you explain what that does?

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

    Re: CommandBars doesn't support property or method

    Basically it gives you access to the 5 events for programming an AddIn. See here for a better explaination.

    http://msdn.microsoft.com/library/de...ty2library.asp
    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

  37. #37

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    24

    Re: CommandBars doesn't support property or method

    Now the next problem - deleting the button if the add-in is removed. Deleting the button was a piece of cake when it was on the Application.CommandBar. Now it's on an Inspector window. When the user removes the add-in he has a dialog window from Options open. It is some sort of modal window and I can't figure out how to set a reference to the InBox MAPI folder CommandBar to delete the button. It gives me an error about a dialog window being open. Any idea if there is any way to get around this?

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

    Re: CommandBars doesn't support property or method

    Post the activeinspector code. It shouldnt be added globally. Only per the single active instance.
    Last edited by RobDog888; Dec 28th, 2005 at 10:53 PM.
    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

  39. #39

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    24

    Re: CommandBars doesn't support property or method

    This code will delete the button. If it is run, however, from the OnDisconnect it gets the error "A dialog box is open. Close it and try again."

    The dialog box that is open is the Options dialog to remove the COM add-in. I can't see any wat to remove the COM add-in without having a dialog box open.

    VB Code:
    1. Dim oItem As outlook.MailItem
    2.         Dim NS As outlook.NameSpace
    3.         Dim objF As MAPIFolder
    4.         Dim cbrMenu As Office.CommandBar
    5.         Dim ctlButton As Office.CommandBarButton
    6.        
    7.         Set NS = Application.GetNamespace("MAPI")
    8.         Set objF = NS.GetDefaultFolder(olFolderInbox)
    9.         Set oItem = objF.Items(1)
    10.         oItem.Display
    11.  
    12.         Set cbrMenu = gobjAppInstance.ActiveInspector.CommandBars(CBR_NAME)
    13.        
    14.         Set ctlButton = cbrMenu.FindControl(Tag:=CTL_KEY)
    15.         ctlButton.Delete

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

    Re: CommandBars doesn't support property or method

    The problem is that your adding the button globally/permenantly because the Temporary parameter is not specified and the default is True. It needs to be False. Then you dont have to worry about deleting it.

    VB Code:
    1. Set ctlBtnAddIn = cbrMenu.Controls.Add(Type:=msoControlButton,  Parameter:=CTL_KEY, Temporary:=True)
    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

Page 1 of 2 12 LastLast

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