C
Chuck
I created a VB.net app that opens a current excel workbook, puts some
data in it and saves it.
This works fine on all XP machines. But I am getting an error on win
98 machines.
here a portion of the code...
Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports Microsoft.Office.Core
Public Class Form2
Inherits System.Windows.Forms.Form
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim oSheet As Object
Dim oExcel As New Excel.Application
Dim oBooks As Excel.Workbooks
oBooks = oExcel.Workbooks
Dim oBook = oExcel.Workbooks.Open("C:\MyWorkbook.xls")--> THIS
LINE IS CAUSING THE ERROR
-----------------
************** Exception Text **************
System.NullReferenceException:
Object reference not set to an instance of an object. at
Excel.Workbooks.Open(String Filename, Object UpdateLinks, Object
ReadOnly, Object Format, Object Password, Object WriteResPassword,
Object IgnoreReadOnlyRecommended, Object Origin, Object Delimiter,
Object Editable, Object Notify, Object Converter, Object AddToMru,
Object Local, Object CorruptLoad)
at MyProj.Form2.Button1_Click(Object sender, EventArgs e) in
C:\MyWorkbook.xls Form2.vb:line 161
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32
msg, IntPtr wparam, IntPtr lparam)
data in it and saves it.
This works fine on all XP machines. But I am getting an error on win
98 machines.
here a portion of the code...
Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports Microsoft.Office.Core
Public Class Form2
Inherits System.Windows.Forms.Form
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim oSheet As Object
Dim oExcel As New Excel.Application
Dim oBooks As Excel.Workbooks
oBooks = oExcel.Workbooks
Dim oBook = oExcel.Workbooks.Open("C:\MyWorkbook.xls")--> THIS
LINE IS CAUSING THE ERROR
-----------------
************** Exception Text **************
System.NullReferenceException:
Object reference not set to an instance of an object. at
Excel.Workbooks.Open(String Filename, Object UpdateLinks, Object
ReadOnly, Object Format, Object Password, Object WriteResPassword,
Object IgnoreReadOnlyRecommended, Object Origin, Object Delimiter,
Object Editable, Object Notify, Object Converter, Object AddToMru,
Object Local, Object CorruptLoad)
at MyProj.Form2.Button1_Click(Object sender, EventArgs e) in
C:\MyWorkbook.xls Form2.vb:line 161
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32
msg, IntPtr wparam, IntPtr lparam)