Object Variable Or With Block Variable Not Set

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Paul Morriss
    New Member
    • Nov 2010
    • 5

    Object Variable Or With Block Variable Not Set

    I get this error from an application:

    Code:
    ************** Exception Text **************
    System.NullReferenceException: Object variable or With block variable not set.
       at Microsoft.VisualBasic.CompilerServices.Symbols.Container..ctor(Object Instance)
       at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateGet(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack)
       at VRN2a_Models_Options.Form1.Form1_Load(Object sender, EventArgs e)
       at System.Windows.Forms.Form.OnLoad(EventArgs e)
       at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
       at System.Windows.Forms.Control.Show()
       at VRN2a_Models_Options.MDIParent1.MDIParent1_Load(Object sender, EventArgs e)
       at System.Windows.Forms.Form.OnLoad(EventArgs e)
       at System.Windows.Forms.Form.OnCreateControl()
       at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
       at System.Windows.Forms.Control.CreateControl()
       at System.Windows.Forms.Control.WmShowWindow(Message& m)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
       at System.Windows.Forms.ContainerControl.WndProc(Message& m)
       at System.Windows.Forms.Form.WmShowWindow(Message& m)
       at System.Windows.Forms.Form.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
    
    ************** Loaded Assemblies **************
    mscorlib
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.3615 (GDR.050727-3600)
        CodeBase: file:///c:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
    ----------------------------------------
    VRN2a Models Options
        Assembly Version: 1.0.0.0
        Win32 Version: 1.0.0.0
        CodeBase: file:///C:/Documents%20and%20Settings/morriss_p/Local%20Settings/Apps/2.0/BA8VWVAP.CPT/2Y61TC6P.XBP/vrn2..tion_f15f9888301d2ca9_0001.0000_c3502c14864e9693/VRN2a%20Models%20Options.exe
    ----------------------------------------
    Microsoft.VisualBasic
        Assembly Version: 8.0.0.0
        Win32 Version: 8.0.50727.3053 (netfxsp.050727-3000)
        CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.VisualBasic/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll
    ----------------------------------------
    System
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.3614 (GDR.050727-3600)
        CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
    ----------------------------------------
    System.Windows.Forms
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
        CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
    ----------------------------------------
    System.Drawing
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
        CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
    ----------------------------------------
    System.Runtime.Remoting
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
        CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Runtime.Remoting/2.0.0.0__b77a5c561934e089/System.Runtime.Remoting.dll
    ----------------------------------------
    Microsoft.Office.Interop.Excel
        Assembly Version: 11.0.0.0
        Win32 Version: 11.0.5530
        CodeBase: file:///C:/WINDOWS/assembly/GAC/Microsoft.Office.Interop.Excel/11.0.0.0__71e9bce111e9429c/Microsoft.Office.Interop.Excel.dll
    ----------------------------------------
    Accessibility
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
        CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Accessibility/2.0.0.0__b03f5f7f11d50a3a/Accessibility.dll
    ----------------------------------------
    AxInterop.SHDocVw
        Assembly Version: 1.1.0.0
        Win32 Version: 1.1.0.0
        CodeBase: file:///C:/Documents%20and%20Settings/morriss_p/Local%20Settings/Apps/2.0/BA8VWVAP.CPT/2Y61TC6P.XBP/vrn2..tion_f15f9888301d2ca9_0001.0000_c3502c14864e9693/AxInterop.SHDocVw.DLL
    ----------------------------------------
    Interop.SHDocVw
        Assembly Version: 1.1.0.0
        Win32 Version: 1.1.0.0
        CodeBase: file:///C:/Documents%20and%20Settings/morriss_p/Local%20Settings/Apps/2.0/BA8VWVAP.CPT/2Y61TC6P.XBP/vrn2..tion_f15f9888301d2ca9_0001.0000_c3502c14864e9693/Interop.SHDocVw.DLL
    ----------------------------------------
    The application runs fine on the developement PC, but not on another PC.
    It looks like the error is here somewhere:



    Code:
    Imports Microsoft.Office.Interop.Excel 
    
    
    Imports AxMicrosoft.Office.Interop.Owc11 
    
    
    Public Class Form1 
    
    Inherits System.Windows.Forms.Form 
    
    Public oDocument As Microsoft.Office.Interop.Excel.Workbook 
    
    Public CSDWkBook As Microsoft.Office.Interop.Excel.Workbook 
    
    Public CSDApp As Microsoft.Office.Interop.Excel._Application 
    
    Public oDocApp As Microsoft.Office.Interop.Excel._Application 
    
    Public AppPath As String = System.AppDomain.CurrentDomain.BaseDirectory
    
    
    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 
    
    Dim UnitWrkBk As String
    
    
    Dim IndTenDigit As String = Strings.Left(Navigate_Form.IndUnitsComboBox.Text, 10) 
    
    Dim IndEditType As String = Strings.Left(EditCSD.IndUnitType, 15) 
    
    Me.WindowState = FormWindowState.Maximized 
    
    'Determine with unit workbook to open
    
    
    
    
    If Navigate_Form.RadioButtonVRN2aFO.Checked = True Then
    
    UnitWrkBk = AppPath & "Excel Files\vrn2a.xls"
    
    Me.AxWebBrowser1.Navigate(UnitWrkBk) 
    
    ElseIf IndTenDigit = "THM0010433" Or IndTenDigit = "THM0010425" Or IndEditType = "Sabre VRN2a Ind" Then
    
    
    UnitWrkBk = AppPath & "Excel Files\vrn2aInd.xls"
    
    Me.AxWebBrowser1.Navigate(UnitWrkBk) 
    
    ElseIf Navigate_Form.RadioButtonVRN6aFO.Checked = True Then
    
    
    UnitWrkBk = AppPath & "Excel Files\vnr6a.xls"
    
    Me.AxWebBrowser1.Navigate(UnitWrkBk) 
    
    ElseIf IndTenDigit = "THM0010413" Then
    
    
    UnitWrkBk = AppPath & "Excel Files\VRN6aInd.xls"
    
    Me.AxWebBrowser1.Navigate(UnitWrkBk) 
    
    ElseIf Navigate_Form.RadioButtonVREaFO.Checked = True Then
    
    
    UnitWrkBk = AppPath & "Excel Files\VREa.xls"
    
    Me.AxWebBrowser1.Navigate(UnitWrkBk) 
    
    ElseIf IndTenDigit = "THM0010417" Or IndTenDigit = "THM0010420" Then
    
    
    UnitWrkBk = AppPath & "Excel Files\VREaInd.xls"
    
    Me.AxWebBrowser1.Navigate(UnitWrkBk) 
    
    ElseIf Navigate_Form.RadioButtonVCEaFO.Checked = True Then
    
    
    UnitWrkBk = AppPath & "Excel Files\VCEa.xls"
    
    Me.AxWebBrowser1.Navigate(UnitWrkBk) 
    
    ElseIf IndTenDigit = "THM0010440" Or IndTenDigit = "THM0010438" Or IndTenDigit = "THM0010434" Then
    
    
    UnitWrkBk = AppPath & "Excel Files\VCEaInd.xls"
    
    Me.AxWebBrowser1.Navigate(UnitWrkBk) 
    
    ElseIf Navigate_Form.RadioButtonSSEaFO.Checked = True Then
    
    
    UnitWrkBk = AppPath & "Excel Files\SSEa.xls"
    
    Me.AxWebBrowser1.Navigate(UnitWrkBk) 
    
    ElseIf IndTenDigit = "THM0010441" Then
    
    
    UnitWrkBk = AppPath & "Excel Files\SSEaInd.xls"
    
    Me.AxWebBrowser1.Navigate(UnitWrkBk) 
    
    ElseIf Navigate_Form.RadioButtonDSEaFO.Checked = True Then
    
    
    UnitWrkBk = AppPath & "Excel Files\DSEa.xls"
    
    Me.AxWebBrowser1.Navigate(UnitWrkBk) 
    
    ElseIf IndTenDigit = "THM0010474" Then
    
    
    UnitWrkBk = AppPath & "Excel Files\DSEaInd.xls"
    
    Me.AxWebBrowser1.Navigate(UnitWrkBk) 
    
    ElseIf Navigate_Form.RadioButtonAMUFO.Checked = True Then
    
    
    UnitWrkBk = AppPath & "Excel Files\AMU.xls"
    
    Me.AxWebBrowser1.Navigate(UnitWrkBk) 
    
    End If
    
    
    oDocApp = AxWebBrowser1.Document.Application
    
    oDocument = AxWebBrowser1.Document
    
    oDocApp.DisplayFormulaBar = False 
    
     
    
    
    End Sub


    Thank you
    Last edited by Stewart Ross; Nov 30 '10, 09:20 AM. Reason: Added code tags
Working...