2013-05-28 25 views
0

這裏IM創建Outlook插件在哪裏我創建一個菜單欄項目,並添加菜單上的一個按鈕bar.when我運行該應用程序,我得到一個運行時錯誤「值不在預期的範圍內」,在MyMenuBar ()方法初始化_objNewMenuBar。任何一個可以建議我爲什麼它給了我這樣的類型或error.this是一個堆棧跟蹤值wherei m到處錯誤
在Microsoft.Office.Core.CommandBarControls.Add(對象類型,對象ID,目標參數,對象之前,對象臨時) 在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 

回答

0

解從方法

刪除所有丟失的可變
相關問題