findcontrol error in vb.net

Add-in Express™ Support Service
That's what is more important than anything else

findcontrol error in vb.net
Having trouble making findcontrol work 
Kevin Wornell




Posts: 36
Joined: 2006-08-14
I am using the following code to try and find out if the ReplyTo All button is disabled when I open an existing email. It fails at the findcontrol line.

[/CODE]
Private Sub adxOutlookEvents_NewInspector(ByVal sender As Object, ByVal ObjInspector As Object, ByVal folderName As String) Handles adxOutlookEvents.NewInspector
Dim MyItem As Outlook.MailItem
Dim myCheck As Object
If (TypeOf (ObjInspector.CurrentItem) Is Outlook.MailItem) Then
MyItem = ObjInspector.CurrentItem
MsgBox("this is a mailitem")
myCheck = OutlookApp.ActiveInspector.CommandBars.FindControl(, 355, , )
If myCheck.Enabled = False Then
MsgBox("Reply all Disabled")
End If
End If
End Sub


Any help greatly appreciated.
hacking my way through life, one syntax error at a time
Posted 14 Aug, 2006 13:36:13 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Kevin.

Please try the following code:

Private Sub adxOutlookEvents_NewInspector(ByVal sender As System.Object, ByVal inspector As System.Object, ByVal folderName As System.String) Handles adxOutlookEvents.NewInspector
Dim myControl As Object = Nothing
Dim MyItem As Outlook.MailItem = Nothing
Dim itemObj As Object = Nothing

Try
itemObj = inspector.CurrentItem
If (TypeOf (itemObj) Is Outlook.MailItem) Then
MyItem = itemObj
Me.CommandBarsObj = inspector.CommandBars
myControl = Me.FindControlObj(Microsoft.Office.Core.MsoControlType.msoControlButton, 355)
If myControl.Enabled = False Then
MsgBox("Reply all Disabled")
End If
End If
Finally
Me.CommandBarsObj = Nothing
If Not myControl Is Nothing Then
Marshal.ReleaseComObject(myControl)
End If
If Not itemObj Is Nothing Then
Marshal.ReleaseComObject(itemObj)
End If
End Try
End Sub
Posted 16 Aug, 2006 06:59:55 Top