Connecting Tech Pros Worldwide Forums | Help | Site Map

How i can control an Excel worksheet by VB 6.0

Newbie
 
Join Date: Jan 2007
Posts: 3
#1: Jan 13 '07
I have an excel worsheet and its divided into 7 Columns and 35 rows
and i want to design an VB project wich have 8 text boxes & one command button
one textbox to put a string value in it to search the excel worksheet by clicking a command button ........ when the needed value is found the vb project fillup the other 7 text boxes with the values of the other rows
if there any one can help me with that..plz

Moderator
 
Join Date: Oct 2006
Location: Australia
Posts: 7,748
#2: Jan 13 '07

re: How i can control an Excel worksheet by VB 6.0


Quote:

Originally Posted by hamoraby

I have an excel worsheet and its divided into 7 Columns and 35 rows
and i want to design an VB project wich have 8 text boxes & one command button
one textbox to put a string value in it to search the excel worksheet by clicking a command button ........ when the needed value is found the vb project fillup the other 7 text boxes with the values of the other rows
if there any one can help me with that..plz

How rigid are these requirements? For example...
  • Does it have to be a VB6 project, or could you use an Excel macro?
  • Does the information have to be in a spreadsheet?
Newbie
 
Join Date: Jan 2007
Posts: 3
#3: Jan 14 '07

re: How i can control an Excel worksheet by VB 6.0


Quote:

Originally Posted by Killer42

How rigid are these requirements? For example...

  • Does it have to be a VB6 project, or could you use an Excel macro?
  • Does the information have to be in a spreadsheet?


Yes it must be a VB project cauz my study within it
and they dont have to be in spreadsheet ...... any way will be helpful.


Thanks in advance
Lives Here
 
Join Date: Oct 2006
Posts: 1,626
#4: Jan 15 '07

re: How i can control an Excel worksheet by VB 6.0


Quote:

Originally Posted by hamoraby

I have an excel worsheet and its divided into 7 Columns and 35 rows
and i want to design an VB project wich have 8 text boxes & one command button
one textbox to put a string value in it to search the excel worksheet by clicking a command button ........ when the needed value is found the vb project fillup the other 7 text boxes with the values of the other rows
if there any one can help me with that..plz

This is relatively easy if you already know how to use automation in your vb project. If you don't already know then you have a lot to learn to get this project to work.

You need to add excel to your list of references so that you can declare variables that refer to an excel workbook. This is quite a lengthy topic to cover here so you might consider doing a google search for 'vb excel automation'

You can also find a code sample here
Newbie
 
Join Date: Jan 2007
Posts: 3
#5: Jan 15 '07

re: How i can control an Excel worksheet by VB 6.0


Quote:

Originally Posted by willakawill

This is relatively easy if you already know how to use automation in your vb project. If you don't already know then you have a lot to learn to get this project to work.

You need to add excel to your list of references so that you can declare variables that refer to an excel workbook. This is quite a lengthy topic to cover here so you might consider doing a google search for 'vb excel automation'

You can also find a code sample here


this code below is all what I got

Private Sub searchbtn_Click()
Dim exelAPP As Excel.Application
Dim exelbook As Excel.Workbook
Dim exelsheet As Excel.Worksheet

Set exelAPP = New Excel.Application
Set exelbook = oXL.Workbooks.Open("d:\d.xls")
Set exelsheet = oWB.Worksheets("Sheet1")
exelsheet.Range("b3", "b34").FindNext (t1.Text) ' i suppose this will search the worksheet of the specefied word

End Sub


then what???!!! when the specefied word is found ..how can i paste the other values of the same row in the other 7 text boxes??????
i dont have any idea how to make the project going ok
Thanks to all
Reply


Similar Visual Basic 4 / 5 / 6 bytes