|
-
Sep 24th, 2005, 11:09 PM
#1
Thread Starter
Junior Member
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.
-
Sep 24th, 2005, 11:22 PM
#2
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Sep 24th, 2005, 11:24 PM
#3
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Sep 24th, 2005, 11:45 PM
#4
Thread Starter
Junior Member
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:
' ------------------------------------------
' This is the shared code module --- Randy
' ------------------------------------------
Option Explicit
' Global variable to store reference to host application.
Public gobjAppInstance As Object
' Constants for characters surrounding ProgID.
Public Const PROG_ID_START As String = "!<"
Public Const PROG_ID_END As String = ">"
' Constants for menu item in Office application.
Public Const CBR_NAME As String = "Tools"
Public Const CTL_CAPTION As String = "My &COM Add-in"
Public Const CTL_KEY As String = "MyCOMAddIn"
Public Const CTL_NAME As String = "My COM Add-in"
Sub AddInErr(errX As ErrObject)
' Displays message box with error information.
Dim strMsg As String
strMsg = "An error occurred in the COM add-in named '" _
& App.Title & "'." & vbCrLf & "Error #:" & errX.Number _
& vbCrLf & errX.Description
MsgBox strMsg, , "Error!"
End Sub
Function CreateAddInCommandBarButton(ByVal Application As Object, _
ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, _
ByVal AddInInst As Object) As Office.CommandBarButton
' This procedure assigns a reference to the Application
' object passed to the OnConnection event to a global
' object variable. It then creates a new command bar
' button and returns a reference to the button to the
' OnConnection event procedure. The advantage to
' putting this code in a public module is that if you
' have more than one add-in designer in the project, you can
' call this procedure from each of them rather than
' duplicating the code.
Dim cbrMenu As Office.CommandBar
Dim ctlBtnAddIn As Office.CommandBarButton
On Error GoTo CreateAddInCommandBarButton_Err
' Return reference to Application object and store it in public variable
' so that other procedures in add-in can use it.
Set gobjAppInstance = Application
' Return reference to command bar.
' This is the line that errors --- Randy
Set cbrMenu = gobjAppInstance.CommandBars(CBR_NAME)
' Add button to call add-in from command bar, if it doesn't
' already exist.
' Constants are declared at module level.
' Look for button on command bar.
Set ctlBtnAddIn = cbrMenu.FindControl(Tag:=CTL_KEY)
If ctlBtnAddIn Is Nothing Then
' Add new button.
Set ctlBtnAddIn = cbrMenu.Controls.Add(Type:=msoControlButton, _
Parameter:=CTL_KEY)
' Set button's Caption, Tag, Style, and OnAction properties.
With ctlBtnAddIn
.Caption = CTL_CAPTION
.Tag = CTL_KEY
.Style = msoButtonCaption
' Use AddInInst argument to return reference
' to this add-in.
.OnAction = PROG_ID_START & AddInInst.ProgId _
& PROG_ID_END
End With
End If
' Return reference to new commandbar button.
Set CreateAddInCommandBarButton = ctlBtnAddIn
CreateAddInCommandBarButton_End:
Exit Function
CreateAddInCommandBarButton_Err:
' Call generic error handler for add-in.
AddInErr Err
Resume CreateAddInCommandBarButton_End
End Function
Function RemoveAddInCommandBarButton(ByVal _
RemoveMode As AddInDesignerObjects.ext_DisconnectMode)
' This procedure removes the command bar button for
' the add-in if the user disconnected it.
On Error GoTo RemoveAddInCommandBarButton_Err
' If user unloaded add-in, remove button. Otherwise, add-in is
' being unloaded because application is closing; in that case,
' leave button as is.
If RemoveMode = ext_dm_UserClosed Then
On Error Resume Next
' Delete custom command bar button.
gobjAppInstance.CommandBars(CBR_NAME).Controls(CTL_NAME).Delete
On Error GoTo RemoveAddInCommandBarButton_Err
End If
RemoveAddInCommandBarButton_End:
Exit Function
RemoveAddInCommandBarButton_Err:
AddInErr Err
Resume RemoveAddInCommandBarButton_End
End Function
' ------------------------------------------
' This is the code from the Designer Module --- Randy
' ------------------------------------------
Option Explicit
' Implement extensibility library.
Implements IDTExtensibility2
' Private module-level variables.
Private WithEvents p_mctlBtnEvents As Office.CommandBarButton
Private p_frmCOMAddIn As frmCOMAddIn
Private Sub AddinInstance_Initialize()
' Initialize event procedure for add-in designer class.
' Create private instance of form, but don't show it.
' Creating a private reference to the form and destroying
' it when the add-in is disconnected ensures that no
' instances of the form will be left in memory.
Set p_frmCOMAddIn = New frmCOMAddIn
End Sub
Private Sub AddinInstance_Terminate()
' Terminate event procedure for add-in designer class.
' Destroy private instance of form.
Unload p_frmCOMAddIn
Set p_frmCOMAddIn = Nothing
End Sub
'------------------------------------------------------
' This event occurs when the user clicks the menu
' command for the add-in in the Office application.
'------------------------------------------------------
Private Sub p_mctlBtnEvents_Click(ByVal Ctrl As Office.CommandBarButton, _
CancelDefault As Boolean)
On Error GoTo Event_Err
' Show form.
p_frmCOMAddIn.Show
Event_End:
Exit Sub
Event_Err:
AddInErr Err
Resume Event_End
End Sub
Private Sub IDTExtensibility2_OnBeginShutdown(custom() As Variant)
' Debug.Print OnBeginShutdown
End Sub
'------------------------------------------------------
' Runs when add-in loads in Office application
' Can run when user loads add-in from Office COM Add-Ins dialog box,
' on startup, or when another application loads add-in.
'------------------------------------------------------
Private Sub IDTExtensibility2_OnConnection(ByVal Application As Object, _
ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, _
ByVal AddInInst As Object, custom() As Variant)
' Call shared code to create new command bar button
' and return reference to it. Assign reference to
' event-ready CommandBarButton object declared with
' WithEvents within this module.
Set p_mctlBtnEvents = CreateAddInCommandBarButton(Application, ConnectMode, _
AddInInst)
End Sub
'-----------------------------------------------------------
' Runs when add-in is unloaded from Office application.
' Can run when user manually unloads add-in from Office
' COM Add-Ins dialog box, when application shuts down, or
' when another application unloads the add-in.
'-----------------------------------------------------------
Private Sub IDTExtensibility2_OnDisconnection(ByVal _
RemoveMode As AddInDesignerObjects.ext_DisconnectMode, _
custom() As Variant)
' Call common procedure to disconnect add-in.
RemoveAddInCommandBarButton RemoveMode
End Sub
Private Sub IDTExtensibility2_OnStartupComplete(custom() As Variant)
'Debug.Print "OnStartupComplete"
End Sub
Private Sub IDTExtensibility2_OnAddInsUpdate(custom() As Variant)
'Debug.Print "OnAddInsUpdate"
End Sub
-
Sep 24th, 2005, 11:51 PM
#5
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:
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Sep 24th, 2005, 11:55 PM
#6
Thread Starter
Junior Member
Re: CommandBars doesn't support property or method
 Originally Posted by RobDog888
VB Code:
Set cbrMenu = gobjAppInstance.CommandBars("Menu Bar")
I changed the line to "Menu Bar", still get the same error.
-
Sep 25th, 2005, 12:06 AM
#7
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Sep 25th, 2005, 12:13 AM
#8
Thread Starter
Junior Member
Re: CommandBars doesn't support property or method
Nothing. The intellisense doesn't respond at all.
-
Sep 25th, 2005, 12:20 AM
#9
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:
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Sep 25th, 2005, 12:27 AM
#10
Thread Starter
Junior Member
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
-
Sep 25th, 2005, 12:45 AM
#11
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:
Public gobjAppInstance As Object
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Sep 25th, 2005, 12:59 AM
#12
Thread Starter
Junior Member
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?
-
Sep 25th, 2005, 01:04 AM
#13
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Sep 25th, 2005, 01:58 AM
#14
Thread Starter
Junior Member
Re: CommandBars doesn't support property or method
It is very close. If I use:
VB Code:
Public gobjAppInstance As Outlook.Application
It works perfectly. Creates the button fine, which works.
If I use:
VB Code:
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
-
Sep 25th, 2005, 04:15 PM
#15
Thread Starter
Junior Member
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?
-
Sep 25th, 2005, 04:18 PM
#16
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Sep 25th, 2005, 05:06 PM
#17
Thread Starter
Junior Member
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?
-
Sep 25th, 2005, 06:40 PM
#18
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Sep 25th, 2005, 08:59 PM
#19
Thread Starter
Junior Member
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?
-
Sep 25th, 2005, 09:09 PM
#20
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Sep 25th, 2005, 09:16 PM
#21
Re: CommandBars doesn't support property or method
Something like this...
VB Code:
Public WithEvents oInsp As Outlook.Inspectors
Private Sub oInsp_NewInspector(ByVal Inspector As Inspector)
Select Case Inspector.CurrentItem.MessageClass
Case "IPM.Note"
'Add buttons relevant to email items
Case "IPM.AppointmentItem"
'Add buttons relevant to Appointment Items
End Select
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Sep 25th, 2005, 10:18 PM
#22
Thread Starter
Junior Member
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?
-
Sep 26th, 2005, 09:07 AM
#23
Thread Starter
Junior Member
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.
-
Sep 26th, 2005, 07:44 PM
#24
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Sep 26th, 2005, 09:29 PM
#25
Thread Starter
Junior Member
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.
-
Sep 26th, 2005, 09:59 PM
#26
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Sep 30th, 2005, 06:19 PM
#27
Thread Starter
Junior Member
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?
-
Sep 30th, 2005, 06:23 PM
#28
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Sep 30th, 2005, 07:07 PM
#29
Thread Starter
Junior Member
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?
-
Sep 30th, 2005, 09:20 PM
#30
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Sep 30th, 2005, 10:32 PM
#31
Thread Starter
Junior Member
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
-
Sep 30th, 2005, 10:35 PM
#32
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Oct 1st, 2005, 12:21 AM
#33
Thread Starter
Junior Member
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.
-
Oct 1st, 2005, 12:28 AM
#34
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Oct 1st, 2005, 01:54 AM
#35
Thread Starter
Junior Member
Re: CommandBars doesn't support property or method
How about that "Implements Extensibility"? Can you explain what that does?
-
Oct 1st, 2005, 11:22 AM
#36
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Oct 1st, 2005, 08:32 PM
#37
Thread Starter
Junior Member
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?
-
Oct 1st, 2005, 09:31 PM
#38
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Oct 1st, 2005, 10:44 PM
#39
Thread Starter
Junior Member
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:
Dim oItem As outlook.MailItem
Dim NS As outlook.NameSpace
Dim objF As MAPIFolder
Dim cbrMenu As Office.CommandBar
Dim ctlButton As Office.CommandBarButton
Set NS = Application.GetNamespace("MAPI")
Set objF = NS.GetDefaultFolder(olFolderInbox)
Set oItem = objF.Items(1)
oItem.Display
Set cbrMenu = gobjAppInstance.ActiveInspector.CommandBars(CBR_NAME)
Set ctlButton = cbrMenu.FindControl(Tag:=CTL_KEY)
ctlButton.Delete
-
Oct 1st, 2005, 10:51 PM
#40
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:
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|