B
BGCSOCAL
I've written programs to create spreadsheets before but never one to read
it. Research is spotty on this. Here is what I have realted to Excel:
Imports System.Data
Imports Microsoft.Office.Interop
Imports System.IO
Public Class frmTest
'Excel-related variables
'Public oXL As Microsoft.Office.Interop.Excel.Application
Public oXL As Excel.Application
Public oWB As Excel.Workbooks
Public oSheet As Excel.Worksheet
Public oRng As Excel.Range
Public indExcel As BooleanI am running VB from VS 2005.
....
'try to open the spreadsheet
Try
oXL = CreateObject("Excel.Application")
oXL.Visible = True
oWB = oXL.Workbooks.Open("c:\Trash\GL Events (3004 items).XLS")
indExcel = True
Catch myException As Exception
'If cannot connect to spreadsheet, then show error
MsgBox("Access to Spreadsheet failed.", MsgBoxStyle.Exclamation,
myException.Message)
indExcel = False
GoTo Close
End Try
Excel opens fine and the spreadsheet loads but I am getting an error
'Microsoft.Office.Interop.Excel.WorkbookClas.....' in the message box.
What have I forgotten to do?
Any help appreciated.
it. Research is spotty on this. Here is what I have realted to Excel:
Imports System.Data
Imports Microsoft.Office.Interop
Imports System.IO
Public Class frmTest
'Excel-related variables
'Public oXL As Microsoft.Office.Interop.Excel.Application
Public oXL As Excel.Application
Public oWB As Excel.Workbooks
Public oSheet As Excel.Worksheet
Public oRng As Excel.Range
Public indExcel As BooleanI am running VB from VS 2005.
....
'try to open the spreadsheet
Try
oXL = CreateObject("Excel.Application")
oXL.Visible = True
oWB = oXL.Workbooks.Open("c:\Trash\GL Events (3004 items).XLS")
indExcel = True
Catch myException As Exception
'If cannot connect to spreadsheet, then show error
MsgBox("Access to Spreadsheet failed.", MsgBoxStyle.Exclamation,
myException.Message)
indExcel = False
GoTo Close
End Try
Excel opens fine and the spreadsheet loads but I am getting an error
'Microsoft.Office.Interop.Excel.WorkbookClas.....' in the message box.
What have I forgotten to do?
Any help appreciated.