以下は私のコードです。問題は、Excelワークシートにフィールドを追加していないことです。HTMLからデータを受け取り、Excelに送信するにはどうすればいいですか?
<! DOCTYPE html>
<Html>
<Head>
<script language="vbscript" type="text/vbscript">
Sub Sample()
Dim iRow
Set objExcel = CreateObject ("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open ("C:\Users\ARPIT SHAJU\Desktop\Church\Member.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 ("surname") (0).Value
.Cells (iRow, 3).value=Document.GetElementsByName ("gender") (0).Value
.Cells (iRow, 4).value=Document.GetElementsByName ("mstatus") (0).Value
.Cells (iRow, 5).value=Document.GetElementsByName ("dob") (0).Value
.Cells (iRow, 6).value=Document.GetElementsByName ("doa") (0).Value
.Cells (iRow, 7).value=Document.GetElementsByName ("baptised") (0).Value
.Cells (iRow, 8).value=Document.GetElementsByName ("residence") (0).Value
.Cells (iRow, 9).value=Document.GetElementsByName ("mnumber") (0).Value
MsgBox "Data Added Successfully”, vbinformation
Document.GetElementsByName ("fname") (0).Value=""
Document.GetElementsByName ("surname") (0).Value=""
Document.GetElementsByName ("gender") (0).Value=""
Document.GetElementsByName ("mstatus") (0).Value=""
Document.GetElementsByName ("dob") (0).Value=""
Document.GetElementsByName ("doa") (0).Value=""
Document.GetElementsByName ("baptised") (0).Value=""
Document.GetElementsByName ("residence") (0).Value=""
Document.GetElementsByName ("mnumber") (0).Value=""
End With
ObjWorkbook. Save
ObjWorkbook. Close
Set objWorkbook = Nothing
Set objExcel = Nothing
End Sub
</script>
<style type="text/css">
fieldset {
border: #00cc00 2px solid;
padding: 10px;
color: green;
</style>
<body
<form>
<fieldset>
<legend>Csharpcorner</legend>
<center>
First name:<br>
<input type="text" name="fname" Value=""><br>
Surname:<br>
<input type="text" name="surname" Value=""><br>
Gender :<br>
<input type="text" name="gender" Value=""><br>
Marital Status :<br>
<input type="text" name="mstatus" Value=""><br>
Date of Birth :<br>
<input type="text" name="dob" Value=""><br>
<br>
Marriage Date :<br>
<input type="text" name="doa" Value=""><br>
Baptised :<br>
<input type="text" name="baptised" Value=""><br>
Residence :<br>
<input type="text" name="residence" Value=""><br>
Mobile Number :<br>
<input type="text" name="mnumber" Value=""><br>
<input type="button" onclick="Sample()" value="Submit"><br>
</center>
</fieldset>
<form>
</body>
</html>
私は自分のExcelとメモ帳を同じフォルダに持っています。コードの何が間違っていますか?ワークシートに値を追加するにはどうすればよいですか?私はデータベースやサーバーなしでそれを使用したいと思います。これは人員のためのオフライン形式です。もっと良い解決策は大歓迎です。
あなたは.HTAファイルとしてではなく、 "メモ帳" として、そのコードを保存する必要があります。 – omegastripes
そのHTMLを開いているソフトウェアは何ですか?デベロッパーツールでコンソールに表示されるエラーは何ですか? – Quentin
私は拡張子.htmのメモ帳を保存してインターネットエクスプローラで開いた – Neethu