如何通過使用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