如何通过使用java脚本发送表单数据,如用户名和电子邮件字段数据,然后通过单击按钮将其存储在excel文件中,并且该代码应该可以在所有浏览器上运行? ? 在我在IE中执行脚本标签下运行这个vb代码之前,我也看不到在该excel文件中填充的任何数据。如何将html格式的数据发送到excel文件
Sub sample()
Dim iRow
Set objExcel = CreateObject ("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open("D:\Users\users.xlsx")
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 Successfully”, 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