Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old December 9th, 2004, 11:20 PM
cyq cyq is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 3 cyq User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
excel and vb

hi,

i am new to vb and was figuring how to get my data in excel worksheet to vb. can anyone help me? thanks in advance.

Reply With Quote
  #2  
Old December 10th, 2004, 01:05 AM
satishkumarj satishkumarj is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 109 satishkumarj User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 1 h 37 m
Reputation Power: 4
Quote:
Originally Posted by cyq
hi,

i am new to vb and was figuring how to get my data in excel worksheet to vb. can anyone help me? thanks in advance.

Hi,

I have written some function to read data from the excel file ,


'FileName should be physical path like "c:\temp\test.xls"
Private Sub ReadXLSFileFormat(FileName As String)

Dim objInputXLS As Object
Dim ObjInputWorkBook As Object
Dim ObjInputSheet As Object

Set objInputXLS = CreateObject("Excel.Application")

Set ObjInputWorkBook = objInputXLS.Workbooks.Open(FileName)
Set ObjInputSheet = ObjInputWorkBook.Worksheets(1)

MsgBox ObjInputSheet.Cells(1,1) ' It will give the data in the 1st row 1st column data in the excel file.

objInputXLS.ActiveWorkbook.Close True, FileName
Set ObjInputSheet = Nothing
Set ObjInputWorkBook = Nothing
Set objInputXLS = Nothing

End Sub


There is another way also there to read excel file using ADOBD.Connection and ADOBD.RecordSet if need that , u ask me again
i can provide u.....


Cheers,

Satish Kumar J...

Reply With Quote
  #3  
Old December 10th, 2004, 02:25 AM
cyq cyq is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 3 cyq User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
hi,

thanks.. may i know where did i write the code at? what are the neccessary steps that i need to do? i appreciate your help.

Reply With Quote
  #4  
Old December 10th, 2004, 02:53 AM
satishkumarj satishkumarj is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 109 satishkumarj User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 1 h 37 m
Reputation Power: 4
Quote:
Originally Posted by cyq
hi,

thanks.. may i know where did i write the code at? what are the neccessary steps that i need to do? i appreciate your help.


Hi,

Create New Vb EXE project and draw a command button on the form and paste the following code in the form1's code place


Private Sub Command1_Click()
'File shoud be there in the specified location
ReadXLSFileFormat ("c:\test.xls")
End Sub

Private Sub ReadXLSFileFormat(FileName As String)
Dim objInputXLS As Object
Dim ObjInputWorkBook As Object
Dim ObjInputSheet As Object
Set objInputXLS = CreateObject("Excel.Application")
Set ObjInputWorkBook = objInputXLS.Workbooks.Open(FileName)
Set ObjInputSheet = ObjInputWorkBook.Worksheets(1)
MsgBox ObjInputSheet.Cells(1, 1) ' It will give the data in the 1st row 1st column data in the excel file.
objInputXLS.ActiveWorkbook.Close True, FileName
Set ObjInputSheet = Nothing
Set ObjInputWorkBook = Nothing
Set objInputXLS = Nothing
End Sub


Regards,
Satish Kumar J...

Reply With Quote
  #5  
Old December 12th, 2004, 09:27 PM
cyq cyq is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 3 cyq User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
thanks, will it be possible to load the whole excel worksheet into vb? sorry for your time. Thanks.

Reply With Quote
  #6  
Old December 12th, 2004, 09:54 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 22 h 33 m
Reputation Power: 181
What version of VB? What do you mean "load"? Load into what?

cyq, spend a little time with some basic tutorials. www.mvps.org is a good starting place.
__________________
======
Doug G
======
I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain

Reply With Quote
  #7  
Old December 13th, 2004, 02:30 AM
Arjun Arjun is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 43 Arjun User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 m 18 sec
Reputation Power: 4
HI, you can also try like this

Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset

'fromload
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\MyExcel.xls;Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1"""
con.Open

rs.Open "Select * from [sheet1$]", con


Private Sub Command1_Click()
MsgBox rs.GetString

End sub







Quote:
Originally Posted by cyq
hi,

i am new to vb and was figuring how to get my data in excel worksheet to vb. can anyone help me? thanks in advance.

Reply With Quote
  #8  
Old June 9th, 2005, 01:29 AM
adityachs adityachs is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Posts: 2 adityachs User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 m 31 sec
Reputation Power: 0
How to access Excel data

Hi,
My situation is I will generate a report from vb in excel.user update the report and once he clicks on update I need to upadte this data into DB.Here neither user nor program(developer) will save the excel file.Application simply opens EXCEl application in such case how to read data from the opend sheet using ADODB.

Quote:
Originally Posted by Arjun
HI, you can also try like this

Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset

'fromload
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\MyExcel.xls;Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1"""
con.Open

rs.Open "Select * from [sheet1$]", con


Private Sub Command1_Click()
MsgBox rs.GetString

End sub

Reply With Quote
  #9  
Old June 9th, 2005, 01:30 AM
adityachs adityachs is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Posts: 2 adityachs User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 m 31 sec
Reputation Power: 0
Hi,
My situation is I will generate a report from vb in excel.user update the report and once he clicks on update I need to upadte this data into DB.Here neither user nor program(developer) will save the excel file.Application simply opens EXCEl application in such case how to read data from the opend sheet using ADODB.

Quote:
Originally Posted by satishkumarj
Hi,

I have written some function to read data from the excel file ,


'FileName should be physical path like "c:\temp\test.xls"
Private Sub ReadXLSFileFormat(FileName As String)

Dim objInputXLS As Object
Dim ObjInputWorkBook As Object
Dim ObjInputSheet As Object

Set objInputXLS = CreateObject("Excel.Application")

Set ObjInputWorkBook = objInputXLS.Workbooks.Open(FileName)
Set ObjInputSheet = ObjInputWorkBook.Worksheets(1)

MsgBox ObjInputSheet.Cells(1,1) ' It will give the data in the 1st row 1st column data in the excel file.

objInputXLS.ActiveWorkbook.Close True, FileName
Set ObjInputSheet = Nothing
Set ObjInputWorkBook = Nothing
Set objInputXLS = Nothing

End Sub


There is another way also there to read excel file using ADOBD.Connection and ADOBD.RecordSet if need that , u ask me again
i can provide u.....


Cheers,

Satish Kumar J...

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > excel and vb


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT