How do we call MS- Excel in VB?

Answer Posted / sugnaya

place two textbox and commandbuttons in design window
and copy this code in code window
-----------------------
Dim xl As New Excel.Application
Dim xlsheet As Excel.Worksheet
Dim xlwbook As New Excel.Workbook

Private Sub Command1_Click()
Text1.Text = xlsheet.Cells(2, 1)
Text2.Text = xlsheet.Cells(2, 2)
End Sub

Private Sub Command2_Click()
xlsheet.Cells(21, 1) = Text1.Text
xlsheet.Cells(21, 2) = Text2.Text
xlwbook.Save
End Sub

Private Sub Form_Load()
Set xlwbook = xl.Workbooks.Open("C:\Documents and
Settings\bct20vb\My Documents\sa.xls")
Set xlsheet = xlwbook.Sheets.Item(1)
End Sub

Is This Answer Correct ?    8 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do I do drag & drop between applications?

1216


Is visualvm free?

863


___ Property is used to count no. of items in a combobox.

1154


by writing MACRO CODE,i want to retrive data from one spead sheet to another UI (workbook). control will search cell by cell for each row and load the data in another workbook(UI). ex: custdetails custname lastname locaton mobile pincode custdetails raj tony hyd 555555 521245 servcreqrd srvce# srvcename location srvcepincode servcreqrd 754 drilling hyd 521784 for the above example in the another workbook retrive data like this custname Raj srvce# 754 srvcepincode 521784. while retrieving data control will search cell by cell for each row.

1941


Is visual basic c#?

693


How do I make my applications screen-resolution independent?

1228


Difference between DDE and OLE.

3014


What is the use of command Object?What are the various types of variables?

804


Is it possible to Access BackEnd procedures?

1801


Explain about ADO control?

769


What is "Reserved Error -1209"?

1575


Is the Variant type slower than using other variable types?

1301


How would you create properties by using class Builder Wizard?

2289


How do you change the system menu (on the Control-Menu Box)?

1205


What is ado in vb?

715