VB.NET

Moderators: seancampbell
Number of threads: 4022
Number of posts: 10035

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Retreacing data from Excel Posted by rferguson on 22 Nov 2006 at 12:17 PM
As a beginner to VB.NET I need help retrieving data from an EXCEL spreadsheet into a VB Listbox. can anyone help with this problem?

Report
Re: Retreacing data from Excel Posted by Juan Garcia on 23 Nov 2006 at 12:14 AM
: As a beginner to VB.NET I need help retrieving data from an EXCEL spreadsheet into a VB Listbox. can anyone help with this problem?
:
: Exactly what are yout trying to do? First, you need to add a reference to the excel object library. After that, you can access the excel object model. But here's a lil code to help you get started:

Dim oExcel As Excel.Application
Dim oDoc As Excel.Workbook
Dim oWorksheet As Excel.Worksheet

oExcel = New Excel.Application
oExcel.Visible = False
'oExcel.WindowState = XlWindowState.xlMinimized

oDoc = oExcel.Workbooks.Open(FileName) 'FileName is the full path and
'name of the excel document.Ex:
'"C:\File.xls"
For i = 1 To oDoc.Worksheets.Count
oWorksheet = oDoc.Worksheets.Item(i) 'Loop through each worksheet
'Now that you have a reference to the worksheet,
'you can access the properties and methods
'of a worksheet to retrieve the data that is needed.
Next

Hope this helps>>>
Report
Re: Retreacing data from Excel Posted by rferguson on 28 Nov 2006 at 1:14 PM
: : As a beginner to VB.NET I need help retrieving data from an EXCEL spreadsheet into a VB Listbox. can anyone help with this problem?
: :
: : Exactly what are yout trying to do? First, you need to add a reference to the excel object library. After that, you can access the excel object model. But here's a lil code to help you get started:
:
: Dim oExcel As Excel.Application
: Dim oDoc As Excel.Workbook
: Dim oWorksheet As Excel.Worksheet
:
: oExcel = New Excel.Application
: oExcel.Visible = False
: 'oExcel.WindowState = XlWindowState.xlMinimized
:
: oDoc = oExcel.Workbooks.Open(FileName) 'FileName is the full path and
: 'name of the excel document.Ex:
: '"C:\File.xls"
: For i = 1 To oDoc.Worksheets.Count
: oWorksheet = oDoc.Worksheets.Item(i) 'Loop through each worksheet
: 'Now that you have a reference to the worksheet,
: 'you can access the properties and methods
: 'of a worksheet to retrieve the data that is needed.
: Next
:
: Hope this helps>>>
:
Why do I get this message
Type Excel.Aplication not defined
I've added the Excel 11.0 object Library from the Add Reference box
is there still something missing?

Report
Re: Retreacing data from Excel Posted by Juan Garcia on 28 Nov 2006 at 9:51 PM
: : : As a beginner to VB.NET I need help retrieving data from an EXCEL spreadsheet into a VB Listbox. can anyone help with this problem?
: : :
: : : Exactly what are yout trying to do? First, you need to add a reference to the excel object library. After that, you can access the excel object model. But here's a lil code to help you get started:
: :
: : Dim oExcel As Excel.Application
: : Dim oDoc As Excel.Workbook
: : Dim oWorksheet As Excel.Worksheet
: :
: : oExcel = New Excel.Application
: : oExcel.Visible = False
: : 'oExcel.WindowState = XlWindowState.xlMinimized
: :
: : oDoc = oExcel.Workbooks.Open(FileName) 'FileName is the full path and
: : 'name of the excel document.Ex:
: : '"C:\File.xls"
: : For i = 1 To oDoc.Worksheets.Count
: : oWorksheet = oDoc.Worksheets.Item(i) 'Loop through each worksheet
: : 'Now that you have a reference to the worksheet,
: : 'you can access the properties and methods
: : 'of a worksheet to retrieve the data that is needed.
: : Next
: :
: : Hope this helps>>>
: :
: Why do I get this message
: Type Excel.Aplication not defined
: I've added the Excel 11.0 object Library from the Add Reference box
: is there still something missing?
:
: did you type application right? or are you using it outside the sub, function, or module that it was declare in?

Report
Re: Retreacing data from Excel Posted by rferguson on 30 Nov 2006 at 10:15 AM
: : : : As a beginner to VB.NET I need help retrieving data from an EXCEL spreadsheet into a VB Listbox. can anyone help with this problem?
: : : :
: : : : Exactly what are yout trying to do? First, you need to add a reference to the excel object library. After that, you can access the excel object model. But here's a lil code to help you get started:
: : :
: : : Dim oExcel As Excel.Application
: : : Dim oDoc As Excel.Workbook
: : : Dim oWorksheet As Excel.Worksheet
: : :
: : : oExcel = New Excel.Application
: : : oExcel.Visible = False
: : : 'oExcel.WindowState = XlWindowState.xlMinimized
: : :
: : : oDoc = oExcel.Workbooks.Open(FileName) 'FileName is the full path and
: : : 'name of the excel document.Ex:
: : : '"C:\File.xls"
: : : For i = 1 To oDoc.Worksheets.Count
: : : oWorksheet = oDoc.Worksheets.Item(i) 'Loop through each worksheet
: : : 'Now that you have a reference to the worksheet,
: : : 'you can access the properties and methods
: : : 'of a worksheet to retrieve the data that is needed.
: : : Next
: : :
: : : Hope this helps>>>
: : :
: : Why do I get this message
: : Type Excel.Aplication not defined
: : I've added the Excel 11.0 object Library from the Add Reference box
: : is there still something missing?
: :
: : did you type application right? or are you using it outside the sub, function, or module that it was declare in?
:
:
This is a Cut and Paste of all the code, I cannot see anything out of the ordinary do you. I am using Visual Studio 2005 with the MSDN Object Libraries installed.

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim oExcel As Excel.Application
Dim oDoc As Excel.Workbook
Dim oWorksheet As Excel.Worksheet

oExcel = New Excel.Application
oExcel.Visible = False
'oExcel.WindowState = XlWindowState.xlMinimized

oDoc = oExcel.Workbooks.Open("C:\bhandicap060926.xls") 'FileName is the full path and
'name of the excel document.Ex:
'"C:\File.xls"
'For i = 1 To oDoc.Worksheets.Count
'oWorksheet = oDoc.Worksheets.Item(i) 'Loop through each worksheet

End Sub
End Class

And this is the frist of 4 errors I get.


Error 1 Type 'Excel.Application' is not defined. C:\Documents and Settings\Randyf\My Documents\Visual Studio 2005\Projects\oExcel\oExcel\Form1.vb 4 23 oExcel



Report
Re: Retreacing data from Excel Posted by Juan Garcia on 30 Nov 2006 at 1:53 PM
: : : : : As a beginner to VB.NET I need help retrieving data from an EXCEL spreadsheet into a VB Listbox. can anyone help with this problem?
: : : : :
: : : : : Exactly what are yout trying to do? First, you need to add a reference to the excel object library. After that, you can access the excel object model. But here's a lil code to help you get started:
: : : :
: : : : Dim oExcel As Excel.Application
: : : : Dim oDoc As Excel.Workbook
: : : : Dim oWorksheet As Excel.Worksheet
: : : :
: : : : oExcel = New Excel.Application
: : : : oExcel.Visible = False
: : : : 'oExcel.WindowState = XlWindowState.xlMinimized
: : : :
: : : : oDoc = oExcel.Workbooks.Open(FileName) 'FileName is the full path and
: : : : 'name of the excel document.Ex:
: : : : '"C:\File.xls"
: : : : For i = 1 To oDoc.Worksheets.Count
: : : : oWorksheet = oDoc.Worksheets.Item(i) 'Loop through each worksheet
: : : : 'Now that you have a reference to the worksheet,
: : : : 'you can access the properties and methods
: : : : 'of a worksheet to retrieve the data that is needed.
: : : : Next
: : : :
: : : : Hope this helps>>>
: : : :
: : : Why do I get this message
: : : Type Excel.Aplication not defined
: : : I've added the Excel 11.0 object Library from the Add Reference box
: : : is there still something missing?
: : :
: : : did you type application right? or are you using it outside the sub, function, or module that it was declare in?
: :
: :
: This is a Cut and Paste of all the code, I cannot see anything out of the ordinary do you. I am using Visual Studio 2005 with the MSDN Object Libraries installed.
:
: Public Class Form1
:
: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
: Dim oExcel As Excel.Application
: Dim oDoc As Excel.Workbook
: Dim oWorksheet As Excel.Worksheet
:
: oExcel = New Excel.Application
: oExcel.Visible = False
: 'oExcel.WindowState = XlWindowState.xlMinimized
:
: oDoc = oExcel.Workbooks.Open("C:\bhandicap060926.xls") 'FileName is the full path and
: 'name of the excel document.Ex:
: '"C:\File.xls"
: 'For i = 1 To oDoc.Worksheets.Count
: 'oWorksheet = oDoc.Worksheets.Item(i) 'Loop through each worksheet
:
: End Sub
: End Class
:
: And this is the frist of 4 errors I get.
:
:
: Error 1 Type 'Excel.Application' is not defined. C:\Documents and Settings\Randyf\My Documents\Visual Studio 2005\Projects\oExcel\oExcel\Form1.vb 4 23 oExcel
:
: This could be it. Did you include the imports statement. The imports statement is usually the first line in any class or module that might using the references: This statement should be on the very top of the code....................
Imports Microsoft.Office.Interop.Excel or Imports Excel

:
:

Report
Need Help. Posted by munirshahzad on 6 Dec 2006 at 2:11 AM
Exactly what are yout trying to do? First, you need to add a reference to the excel object library. After that, you can access the excel object model. But here's a lil code to help you get started:
:
: Dim oExcel As Excel.Application
: Dim oDoc As Excel.Workbook
: Dim oWorksheet As Excel.Worksheet
:
: oExcel = New Excel.Application
: oExcel.Visible = False
: 'oExcel.WindowState = XlWindowState.xlMinimized
:
: oDoc = oExcel.Workbooks.Open(FileName) 'FileName is the full path and
: 'name of the excel document.Ex:
: '"C:\File.xls"
: For i = 1 To oDoc.Worksheets.Count
: oWorksheet = oDoc.Worksheets.Item(i) 'Loop through each worksheet
: 'Now that you have a reference to the worksheet,
: 'you can access the properties and methods
: 'of a worksheet to retrieve the data that is needed.
: Next
:
: Hope this helps>>>
:

Hello,
i want to know that where the file (Excel Object Library) is located and also can MS Access also have a object Library, if yes then please note the location of the file. I want to access MS Access's Menus from VB.Net.
Thanks in advance.
Shahzad Munir.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.