Morning All,
What i am trying to do is create a single web page that has text fields and radio buttons to allow a user to input data using a touch screen prior to hitting a submit button and for that data to be sent to a single excel file.
I found the following code during my google research on the matter which gives me four text fields that i can enter data on and which works with it sending it to a new line each time on the same excel file.
How ever i wish to understand this code to allow me to create a more detailed form with a text boxes, radio buttons and checkboxes.
Code:
<!DOCTYPE html>
<html>
<head>
******** language="vbscript" type="text/vbscript">
Sub Sample()
Dim iRow
Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open("home/Book1.xlsx")
'Document.GetElementsByName("fname")(0).Value="C#"
'Document.GetElementsByName("lname")(0).Value="Corner"
'Document.GetElementsByName("Add1")(0).Value="Tamilnadu"
'Document.GetElementsByName("Add2")(0).Value="Coimbatore"
objExcel.Application.Visible = True
objWorkbook.Windows(1).Visible = True
set XlSheet =objWorkbook.Sheets(1)
XlSheet.Activate
iRow = 1
With objExcel
Do While .Cells(iRow, 1).value <> ""
.Cells(iRow, 1).activate
iRow = iRow + 1
Loop
.Cells(iRow, 1).value=Document.GetElementsByName("fname")(0).Value
.Cells(iRow, 2).value=Document.GetElementsByName("lname")(0).Value
.Cells(iRow, 3).value=Document.GetElementsByName("Add1")(0).Value
.Cells(iRow, 4).value=Document.GetElementsByName("Add2")(0).Value
MsgBox "Data Added Sucessfully",vbinformation
Document.GetElementsByName("fname")(0).Value=""
Document.GetElementsByName("lname")(0).Value=""
Document.GetElementsByName("Add1")(0).Value=""
Document.GetElementsByName("Add2")(0).Value=""
End With
objWorkbook.save
objWorkbook.close
Set objWorkbook = Nothing
Set objExcel = Nothing
End Sub
*********>
******>
<form>
<fieldset>
<center>
First name:<br>
<input type="text" name="fname" Value=""><br>
Last name:<br>
<input type="text" name="lname" Value=""><br>
Address1:<br>
<input type="text" name="Add1" Value=""><br>
Address2 :<br>
<input type="text" name="Add2" Value=""><br>
<br>
<input type="button" *******="Sample()" value="Submit" /><br>
</center>
</fieldset>
</form>
</body>
</html>
Also i am not too sure what the values are for at the ends of the following line of coding? Do the words in "" mean anything to anyone??
'Document.GetElementsByName("fname")(0).Value="C#"
'Document.GetElementsByName("lname")(0).Value="Corner"
'Document.GetElementsByName("Add1")(0).Value="Tamilnadu"
'Document.GetElementsByName("Add2")(0).Value="Coimbatore"
Hope there is someone on this forum who is able to help at all.
I have posted this in other HTML stlye forums but had no luck at all (hope this is ok?)
Kind Regards
P
What i am trying to do is create a single web page that has text fields and radio buttons to allow a user to input data using a touch screen prior to hitting a submit button and for that data to be sent to a single excel file.
I found the following code during my google research on the matter which gives me four text fields that i can enter data on and which works with it sending it to a new line each time on the same excel file.
How ever i wish to understand this code to allow me to create a more detailed form with a text boxes, radio buttons and checkboxes.
Code:
<!DOCTYPE html>
<html>
<head>
******** language="vbscript" type="text/vbscript">
Sub Sample()
Dim iRow
Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open("home/Book1.xlsx")
'Document.GetElementsByName("fname")(0).Value="C#"
'Document.GetElementsByName("lname")(0).Value="Corner"
'Document.GetElementsByName("Add1")(0).Value="Tamilnadu"
'Document.GetElementsByName("Add2")(0).Value="Coimbatore"
objExcel.Application.Visible = True
objWorkbook.Windows(1).Visible = True
set XlSheet =objWorkbook.Sheets(1)
XlSheet.Activate
iRow = 1
With objExcel
Do While .Cells(iRow, 1).value <> ""
.Cells(iRow, 1).activate
iRow = iRow + 1
Loop
.Cells(iRow, 1).value=Document.GetElementsByName("fname")(0).Value
.Cells(iRow, 2).value=Document.GetElementsByName("lname")(0).Value
.Cells(iRow, 3).value=Document.GetElementsByName("Add1")(0).Value
.Cells(iRow, 4).value=Document.GetElementsByName("Add2")(0).Value
MsgBox "Data Added Sucessfully",vbinformation
Document.GetElementsByName("fname")(0).Value=""
Document.GetElementsByName("lname")(0).Value=""
Document.GetElementsByName("Add1")(0).Value=""
Document.GetElementsByName("Add2")(0).Value=""
End With
objWorkbook.save
objWorkbook.close
Set objWorkbook = Nothing
Set objExcel = Nothing
End Sub
*********>
******>
<form>
<fieldset>
<center>
First name:<br>
<input type="text" name="fname" Value=""><br>
Last name:<br>
<input type="text" name="lname" Value=""><br>
Address1:<br>
<input type="text" name="Add1" Value=""><br>
Address2 :<br>
<input type="text" name="Add2" Value=""><br>
<br>
<input type="button" *******="Sample()" value="Submit" /><br>
</center>
</fieldset>
</form>
</body>
</html>
Also i am not too sure what the values are for at the ends of the following line of coding? Do the words in "" mean anything to anyone??
'Document.GetElementsByName("fname")(0).Value="C#"
'Document.GetElementsByName("lname")(0).Value="Corner"
'Document.GetElementsByName("Add1")(0).Value="Tamilnadu"
'Document.GetElementsByName("Add2")(0).Value="Coimbatore"
Hope there is someone on this forum who is able to help at all.
I have posted this in other HTML stlye forums but had no luck at all (hope this is ok?)
Kind Regards
P