By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,515 Members | 1,157 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,515 IT Pros & Developers. It's quick & easy.

Object Variable Or With Block Variable Not Set

P: 5
I get this error from an application:

Expand|Select|Wrap|Line Numbers
  1. ************** Exception Text **************
  2. System.NullReferenceException: Object variable or With block variable not set.
  3.    at Microsoft.VisualBasic.CompilerServices.Symbols.Container..ctor(Object Instance)
  4.    at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateGet(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack)
  5.    at VRN2a_Models_Options.Form1.Form1_Load(Object sender, EventArgs e)
  6.    at System.Windows.Forms.Form.OnLoad(EventArgs e)
  7.    at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
  8.    at System.Windows.Forms.Control.Show()
  9.    at VRN2a_Models_Options.MDIParent1.MDIParent1_Load(Object sender, EventArgs e)
  10.    at System.Windows.Forms.Form.OnLoad(EventArgs e)
  11.    at System.Windows.Forms.Form.OnCreateControl()
  12.    at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
  13.    at System.Windows.Forms.Control.CreateControl()
  14.    at System.Windows.Forms.Control.WmShowWindow(Message& m)
  15.    at System.Windows.Forms.Control.WndProc(Message& m)
  16.    at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
  17.    at System.Windows.Forms.ContainerControl.WndProc(Message& m)
  18.    at System.Windows.Forms.Form.WmShowWindow(Message& m)
  19.    at System.Windows.Forms.Form.WndProc(Message& m)
  20.    at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
  21.    at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
  22.    at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
  23.  
  24. ************** Loaded Assemblies **************
  25. mscorlib
  26.     Assembly Version: 2.0.0.0
  27.     Win32 Version: 2.0.50727.3615 (GDR.050727-3600)
  28.     CodeBase: file:///c:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
  29. ----------------------------------------
  30. VRN2a Models Options
  31.     Assembly Version: 1.0.0.0
  32.     Win32 Version: 1.0.0.0
  33.     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
  34. ----------------------------------------
  35. Microsoft.VisualBasic
  36.     Assembly Version: 8.0.0.0
  37.     Win32 Version: 8.0.50727.3053 (netfxsp.050727-3000)
  38.     CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.VisualBasic/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll
  39. ----------------------------------------
  40. System
  41.     Assembly Version: 2.0.0.0
  42.     Win32 Version: 2.0.50727.3614 (GDR.050727-3600)
  43.     CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
  44. ----------------------------------------
  45. System.Windows.Forms
  46.     Assembly Version: 2.0.0.0
  47.     Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
  48.     CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
  49. ----------------------------------------
  50. System.Drawing
  51.     Assembly Version: 2.0.0.0
  52.     Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
  53.     CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
  54. ----------------------------------------
  55. System.Runtime.Remoting
  56.     Assembly Version: 2.0.0.0
  57.     Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
  58.     CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Runtime.Remoting/2.0.0.0__b77a5c561934e089/System.Runtime.Remoting.dll
  59. ----------------------------------------
  60. Microsoft.Office.Interop.Excel
  61.     Assembly Version: 11.0.0.0
  62.     Win32 Version: 11.0.5530
  63.     CodeBase: file:///C:/WINDOWS/assembly/GAC/Microsoft.Office.Interop.Excel/11.0.0.0__71e9bce111e9429c/Microsoft.Office.Interop.Excel.dll
  64. ----------------------------------------
  65. Accessibility
  66.     Assembly Version: 2.0.0.0
  67.     Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
  68.     CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Accessibility/2.0.0.0__b03f5f7f11d50a3a/Accessibility.dll
  69. ----------------------------------------
  70. AxInterop.SHDocVw
  71.     Assembly Version: 1.1.0.0
  72.     Win32 Version: 1.1.0.0
  73.     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
  74. ----------------------------------------
  75. Interop.SHDocVw
  76.     Assembly Version: 1.1.0.0
  77.     Win32 Version: 1.1.0.0
  78.     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
  79. ----------------------------------------
The application runs fine on the developement PC, but not on another PC.
It looks like the error is here somewhere:



Expand|Select|Wrap|Line Numbers
  1. Imports Microsoft.Office.Interop.Excel 
  2.  
  3.  
  4. Imports AxMicrosoft.Office.Interop.Owc11 
  5.  
  6.  
  7. Public Class Form1 
  8.  
  9. Inherits System.Windows.Forms.Form 
  10.  
  11. Public oDocument As Microsoft.Office.Interop.Excel.Workbook 
  12.  
  13. Public CSDWkBook As Microsoft.Office.Interop.Excel.Workbook 
  14.  
  15. Public CSDApp As Microsoft.Office.Interop.Excel._Application 
  16.  
  17. Public oDocApp As Microsoft.Office.Interop.Excel._Application 
  18.  
  19. Public AppPath As String = System.AppDomain.CurrentDomain.BaseDirectory
  20.  
  21.  
  22. Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 
  23.  
  24. Dim UnitWrkBk As String
  25.  
  26.  
  27. Dim IndTenDigit As String = Strings.Left(Navigate_Form.IndUnitsComboBox.Text, 10) 
  28.  
  29. Dim IndEditType As String = Strings.Left(EditCSD.IndUnitType, 15) 
  30.  
  31. Me.WindowState = FormWindowState.Maximized 
  32.  
  33. 'Determine with unit workbook to open
  34.  
  35.  
  36.  
  37.  
  38. If Navigate_Form.RadioButtonVRN2aFO.Checked = True Then
  39.  
  40. UnitWrkBk = AppPath & "Excel Files\vrn2a.xls"
  41.  
  42. Me.AxWebBrowser1.Navigate(UnitWrkBk) 
  43.  
  44. ElseIf IndTenDigit = "THM0010433" Or IndTenDigit = "THM0010425" Or IndEditType = "Sabre VRN2a Ind" Then
  45.  
  46.  
  47. UnitWrkBk = AppPath & "Excel Files\vrn2aInd.xls"
  48.  
  49. Me.AxWebBrowser1.Navigate(UnitWrkBk) 
  50.  
  51. ElseIf Navigate_Form.RadioButtonVRN6aFO.Checked = True Then
  52.  
  53.  
  54. UnitWrkBk = AppPath & "Excel Files\vnr6a.xls"
  55.  
  56. Me.AxWebBrowser1.Navigate(UnitWrkBk) 
  57.  
  58. ElseIf IndTenDigit = "THM0010413" Then
  59.  
  60.  
  61. UnitWrkBk = AppPath & "Excel Files\VRN6aInd.xls"
  62.  
  63. Me.AxWebBrowser1.Navigate(UnitWrkBk) 
  64.  
  65. ElseIf Navigate_Form.RadioButtonVREaFO.Checked = True Then
  66.  
  67.  
  68. UnitWrkBk = AppPath & "Excel Files\VREa.xls"
  69.  
  70. Me.AxWebBrowser1.Navigate(UnitWrkBk) 
  71.  
  72. ElseIf IndTenDigit = "THM0010417" Or IndTenDigit = "THM0010420" Then
  73.  
  74.  
  75. UnitWrkBk = AppPath & "Excel Files\VREaInd.xls"
  76.  
  77. Me.AxWebBrowser1.Navigate(UnitWrkBk) 
  78.  
  79. ElseIf Navigate_Form.RadioButtonVCEaFO.Checked = True Then
  80.  
  81.  
  82. UnitWrkBk = AppPath & "Excel Files\VCEa.xls"
  83.  
  84. Me.AxWebBrowser1.Navigate(UnitWrkBk) 
  85.  
  86. ElseIf IndTenDigit = "THM0010440" Or IndTenDigit = "THM0010438" Or IndTenDigit = "THM0010434" Then
  87.  
  88.  
  89. UnitWrkBk = AppPath & "Excel Files\VCEaInd.xls"
  90.  
  91. Me.AxWebBrowser1.Navigate(UnitWrkBk) 
  92.  
  93. ElseIf Navigate_Form.RadioButtonSSEaFO.Checked = True Then
  94.  
  95.  
  96. UnitWrkBk = AppPath & "Excel Files\SSEa.xls"
  97.  
  98. Me.AxWebBrowser1.Navigate(UnitWrkBk) 
  99.  
  100. ElseIf IndTenDigit = "THM0010441" Then
  101.  
  102.  
  103. UnitWrkBk = AppPath & "Excel Files\SSEaInd.xls"
  104.  
  105. Me.AxWebBrowser1.Navigate(UnitWrkBk) 
  106.  
  107. ElseIf Navigate_Form.RadioButtonDSEaFO.Checked = True Then
  108.  
  109.  
  110. UnitWrkBk = AppPath & "Excel Files\DSEa.xls"
  111.  
  112. Me.AxWebBrowser1.Navigate(UnitWrkBk) 
  113.  
  114. ElseIf IndTenDigit = "THM0010474" Then
  115.  
  116.  
  117. UnitWrkBk = AppPath & "Excel Files\DSEaInd.xls"
  118.  
  119. Me.AxWebBrowser1.Navigate(UnitWrkBk) 
  120.  
  121. ElseIf Navigate_Form.RadioButtonAMUFO.Checked = True Then
  122.  
  123.  
  124. UnitWrkBk = AppPath & "Excel Files\AMU.xls"
  125.  
  126. Me.AxWebBrowser1.Navigate(UnitWrkBk) 
  127.  
  128. End If
  129.  
  130.  
  131. oDocApp = AxWebBrowser1.Document.Application
  132.  
  133. oDocument = AxWebBrowser1.Document
  134.  
  135. oDocApp.DisplayFormulaBar = False 
  136.  
  137.  
  138.  
  139.  
  140. End Sub


Thank you
Nov 30 '10 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.