【问题标题】:Geting Runtime Error "Value does not fall within the expected range."出现运行时错误“值不在预期范围内。”
【发布时间】:2013-05-28 09:20:27
【问题描述】:

我在这里创建 Outlook 插件。我在其中创建一个菜单栏项目并在菜单栏上添加一个按钮。当我运行应用程序时,我在MyMenuBar() 方法初始化 _objNewMenuBar。谁能建议我为什么它给我这种类型或错误。这是一个堆栈跟踪值,我在 Microsoft.Office.Core.CommandBarControls.Add(Object Type, Object Id, Object Parameter, Object之前,对象临时) 在 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

【问题讨论】:

    标签: vb.net outlook-addin outlook-2007


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-10-23
      • 1970-01-01
      • 1970-01-01
      • 2019-09-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多