User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the VB.NET section within the Software Development category of DaniWeb, a massive community of 402,624 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,140 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our VB.NET advertiser: Programming Forums
Views: 12289 | Replies: 1
Reply
Join Date: Oct 2005
Posts: 1
Reputation: Sharif Lotfi is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Sharif Lotfi Sharif Lotfi is offline Offline
Newbie Poster

use excel in vb.net 2003

  #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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: May 2006
Posts: 1
Reputation: AE5MM is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
AE5MM AE5MM is offline Offline
Newbie Poster

Re: use excel in vb.net 2003

  #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  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb VB.NET Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the VB.NET Forum

All times are GMT -4. The time now is 1:28 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC