Excel Help

  • Thread starter Thread starter alihussain19
  • Start date Start date
A

alihussain19

Hi,
I am not sure if someone could help me in this....
I have a VB form in word with about 5 fields and when I submit it
need to know how to start a an Excel file and enter the data from th
text boxes on that form to the Excel sheet at the first empt
row.....Any Help Will be Appriciated...
Thank
 
Something like

Set xlApp = CreateObject("Excel.Application")
Set xlWB = xlApp.Workbooks.Open "C:\myTest\volker1.xls"
Set xlWS = xlWB.Activesheet
iLastRow = xlWS.Cells(Rows.Count).End(xlUp).Row
With xlWS
.Cells(iLatRow+1,"A").Value = TextBox1.Text
.Cells(iLatRow+1,"B").Value = TextBox2.Text
.Cells(iLatRow+1,"C").Value = TextBox3.Text
.Cells(iLatRow+1,"D").Value = TextBox4.Text
.Cells(iLatRow+1,"E").Value = TextBox5Text
End With

If you want to see the XL app, then add

xlApp.Visible = True

to save the workbook

xlWB.Save

at the end, to quit Excel

xlApp.Quit

You will also need to set a reference to Excel library, VBE
Tools>References.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top