Hello
I need to connection beetween VB.Net 2003 and Excel 2003 and use excel 2003 object
I add Excell 11.0 Library to my project and write this code :
--------------------------------------------------------
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
xlApp = CType(CreateObject("Excel.Application"), Excel.Application)
xlBook = CType(xlApp.Workbooks.Add, Excel.Workbook)
xlSheet = CType(xlBook.Worksheets(1), Excel.Worksheet)
'Insert data
xlSheet.Cells(1, 2) = 5000
-------------------------------------------------------------
but my project stopped in this line :

xlBook = CType(xlApp.Workbooks.Add, Excel.Workbook)

and view this Error :
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in Excel Sheet Tasks.exe
Additional information: Old format or invalid type library.

Please help me to OBVIATION my problem
with thanks,
regards,
sharif lotfi
p_d_1382@yahoo.com

Dim App As New Excel.Application
App.Visible = True
App.Application.SheetsInNewWorkbook = 1

Dim Destination As Excel.Workbook = App.Workbooks.Add()
Dim Destination_Sheet As Excel.Worksheet = Destination.Sheets(1)
'Updates the cells with labels
Destination_Sheet.Range("A1").Value = Now
Destination_Sheet.Range("A2").Value = "CATEGORY"
Destination_Sheet.Range("B2").Value = "DESCRIPTION"

'Set row to insert data
SSRow = 3

'looping occurs here
tempCell = "A" & Trim(Str(SSRow))
Destination_Sheet.Range(tempCell).NumberFormat = "@"
Destination_Sheet.Range(tempCell).Value = Category
tempCell = "B" & Trim(Str(SSRow))
Destination_Sheet.Range(tempCell).Value = Description
tempCell = "C" & Trim(Str(SSRow))
SSRow = SSRow + 1
'looping ends here

'Autofit Columns
Destination_Sheet.Columns.AutoFit()
'Shade Column headers
Destination_Sheet.Range("A2", "C2").Interior.ColorIndex = 15
'Save woorkbook
Destination_Sheet.SaveAs(DestinationPath.Text & "FileName.XLS")
App.Workbooks.Close()
App.Quit()


Maybe this will help,
Loyd

i do have a software source code for getting all the excel data into VB

i do have a software source code for getting all the excel data into VB
u can cont me on 09224447752
m not developer but give projects on freelancing

Hello
I need to connection beetween VB.Net 2003 and Excel 2003 and use excel 2003 object
I add Excell 11.0 Library to my project and write this code :
--------------------------------------------------------
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
xlApp = CType(CreateObject("Excel.Application"), Excel.Application)
xlBook = CType(xlApp.Workbooks.Add, Excel.Workbook)
xlSheet = CType(xlBook.Worksheets(1), Excel.Worksheet)
'Insert data
xlSheet.Cells(1, 2) = 5000
-------------------------------------------------------------
but my project stopped in this line :

xlBook = CType(xlApp.Workbooks.Add, Excel.Workbook)

and view this Error :
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in Excel Sheet Tasks.exe
Additional information: Old format or invalid type library.

Please help me to OBVIATION my problem
with thanks,
regards,
sharif lotfi
p_d_1382@yahoo.com

I found a lot of examples of code that did not work while trying to develop a VB.Net 2003 program that would read Excel 2007 cell contents and return them to variables in my program. After hours of borrowing snippets of code from various posts (because the MSDN documentation just isn't helpful, in my opinion), I was able to get some code to work. This is an old thread but came up high on a Google search so I'm posting it here in case it helps someone in the future. Good luck! Dave

Dim CellRead As String
Dim excel As Microsoft.Office.Interop.Excel.Application
Dim wb As Microsoft.Office.Interop.Excel.Workbook
Dim ws As Microsoft.Office.Interop.Excel.Worksheet
Dim wr As Microsoft.Office.Interop.Excel.Range


Try
excel = CType(CreateObject("Excel.Application"), Microsoft.Office.Interop.Excel.Application)

wb = excel.Workbooks.Open("C:\Yourfile.xls")
excel.Visible = True
wb.Activate()
Catch ex As Exception
MessageBox.Show("Error: " + ex.ToString())
End Try
ws = wb.Sheets(1)
wr = ws.Range("A1", "AB25")
CellRead = wr.Cells.FormulaR1C1(1, 1)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.