0

我在这里创建了 Outlook 插件。我在其中创建了一个菜单栏项并在菜单栏上添加了一个按钮。当我运行应用程序时,我在 MyMenuBar() 中收到运行时错误“值不在预期范围内”初始化 _objNewMenuBar 的方法。谁能建议我为什么它给我这种类型或错误。这是一个堆栈跟踪值,我
在 Microsoft.Office.Core.CommandBarControls.Add(Object Type, Object Id, Object Parameter, Object Before, Object Temporary) 处出现错误TROutlookAddOn.ThisAddIn.MyMenuBar()

Private Sub ThisAddIn_Startup(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Startup
    Me.MyMenuBar()
End Sub

Private Sub MyMenuBar()
    Me.ErsMyMenuBar()
    Try
        'Define the existent Menu Bar
        _objMenuBar = Me.Application.ActiveExplorer.CommandBars.ActiveMenuBar
        'Define the new Menu Bar into the old menu bar
        _objNewMenuBar = CType(_objMenuBar.Controls.Add(Office.MsoControlType.msoControlPopup, missing, missing, missing, False), Office.CommandBarPopup)
        If (Not (_objNewMenuBar) Is Nothing) Then
            _objNewMenuBar.Caption = "Talent Recruit"
            _objNewMenuBar.Tag = menuTag
            _objButton = CType(_objNewMenuBar.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, 1, True), Office.CommandBarButton)
            _objButton.Caption = "Import Resume"
            Dim newIcon As System.Drawing.Icon = My.Resources.recruit_logo
            Dim newImageList As ImageList = New ImageList
            newImageList.Images.Add(newIcon)
            _objButton.Picture = ConvertImage.Convert(newImageList.Images(0))
            _objButton.Style = Microsoft.Office.Core.MsoButtonStyle.msoButtonIconAndCaption
            'Icon 
            '_objButton.FaceId = 500;
            _objButton.Tag = "ItemTag"
            'EventHandler
            AddHandler _objButton.Click, AddressOf Me._objButton_Click
            _objNewMenuBar.Visible = True
        End If
    Catch ex As System.Exception
        System.Windows.Forms.MessageBox.Show(("Error: " + ex.Message.ToString), "Error Message")
    End Try
End Sub
4

1 回答 1

0

从方法中删除所有缺失变量的解决方案

于 2013-05-28T09:54:26.990 回答