【发布时间】:2017-03-17 09:27:40
【问题描述】:
如何使用 java 脚本发送表单数据,如用户名和电子邮件字段数据,然后必须通过单击按钮将其存储在 excel 文件中,并且该代码应在所有浏览器上运行? 在我在 IE 中执行的脚本标记下运行此 vb 代码之前,即使在那里我也看不到该 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
【问题讨论】:
标签: javascript html