Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi Friends,

I have html form when I click submit button .data should be moved to a excel sheet

Again if I entered one more data in html form that should be appended in excel not replace !!

below is the my html file in ...please help me out.

I dont have idea in VBScript. please


<HTML>
<HEAD>

<TITLE>Exporting into Excel</TITLE>

</HEAD>

<SCRIPT Language = "VBScript">

Function Export(P,R)

Set ExcelApp = CreateObject("Excel.application")
ExcelApp.Visible = True

strPathDoc = "D:\atul.xls" 'Your File path

Set myExcelDoc = ExcelApp.Workbooks.Open(strPathDoc)
ExcelApp.Visible = True
myExcelDoc.Windows(1).Visible = True
set XlSheet = myExcelDoc.Worksheets(2)
XlSheet.Range("A6").value=P
XlSheet.Range("A7").value=R
myExcelDoc.save
myExcelDoc.close
Set myExcelDoc = Nothing
Set ExcelApp = Nothing
End Function

Sub cmdExp_OnClick()
Dim lPrincipal
Dim dblRate

Frstnm = Disnm.value
Lstnm = TreatGrp.value
cInterest = Export(Frstnm, Lstnm)

End Sub

< /SCRIPT> <BODY>

First Name: <INPUT Type="Text" Name="Disnm" Value="">

Last Name : <INPUT Type="Text" Name="TreatGrp" Value="">
<INPUT Type="Button"
Name="cmdExp" Value="Connect"> </BODY> </HTML>


Posted
Updated 5-Nov-18 4:34am
v5
Comments
Priyanka1190 29-Jan-15 5:43am    
what are the requirements to run this code?

1 solution

When you assign your values into cells, you should check if these cells have values or not.
For example, if you want to append values vertically: A6, A7, then A8, A9, and the 3rd time is A10, 11,
you can use this:
VB
currentRow = 6
currentVal = XlSheet.Range("A" & currentRow).value
While currentVal <> ""
    currentRow = currentRow + 1
    currentVal = XlSheet.Range("A" & currentRow).value
Wend
XlSheet.Range("A" & currentRow).value = P
XlSheet.Range("A" & (currentRow + 1)).value = R
 
Share this answer
 
Comments
Nagendra Dantam 29-Oct-13 14:03pm    
Can you please provide entire code actually I don’t know VB Script.
thanh_bkhn 29-Oct-13 22:45pm    
Try to replace your cell value assignment with these code

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900