use excel in vb.net 2003

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Oct 2005
Posts: 1
Reputation: Sharif Lotfi is an unknown quantity at this point 
Solved Threads: 0
Sharif Lotfi Sharif Lotfi is offline Offline
Newbie Poster

use excel in vb.net 2003

 
0
  #1
Oct 7th, 2005
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
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 1
Reputation: AE5MM is an unknown quantity at this point 
Solved Threads: 0
AE5MM AE5MM is offline Offline
Newbie Poster

Re: use excel in vb.net 2003

 
0
  #2
May 8th, 2006
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
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 7
Reputation: gever is an unknown quantity at this point 
Solved Threads: 0
gever gever is offline Offline
Newbie Poster

Re: use excel in vb.net 2003

 
0
  #3
Sep 15th, 2008
go through the following link about connect excel file through vb.net.

http://vb.net-informations.com/excel..._open_file.htm

thanks.
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 10
Reputation: harshitkamdar is an unknown quantity at this point 
Solved Threads: 0
harshitkamdar harshitkamdar is offline Offline
Newbie Poster

Re: use excel in vb.net 2003

 
0
  #4
Sep 15th, 2008
i do have a software source code for getting all the excel data into VB
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 10
Reputation: harshitkamdar is an unknown quantity at this point 
Solved Threads: 0
harshitkamdar harshitkamdar is offline Offline
Newbie Poster

Re: use excel in vb.net 2003

 
0
  #5
Sep 15th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 1
Reputation: kolstedt is an unknown quantity at this point 
Solved Threads: 0
kolstedt kolstedt is offline Offline
Newbie Poster

Re: use excel in vb.net 2003

 
0
  #6
Jul 25th, 2009
Originally Posted by Sharif Lotfi View Post
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)
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC