我試圖從Access DB發送數據到網站http://www.lee.vote/voters/check-your-registration-status/。我可以使用類似的代碼(如下)將數據發送到不同的網站,但我無法弄清楚爲什麼它不適用於這個網站。使用MS Access VBA發送數據到網絡表格
從我嘗試填寫HTML:
<div id="FindVoterForm">
<div id="IntroText">
<h1 style="text-align: center; margin-bottom: 3px;">Voter Information in <span id="MainCounty">Lee</span> County</h1>
<h2 style="text-align: center; margin-top: 3px; margin-bottom: 3px;">Sample Ballots and Voting Locations</h2>
<span class="style1" style="margin-bottom: 0px;">Complete the form to see:</span><ul style="margin-top: 0px;">
<li class="style1"><b>Where to vote on election day</b></li>
<li class="style1"><b>Sample ballots</b></li>
<li class="style1"><b>Upcoming elections</b></li>
</ul>
<p class="style2" style="margin-bottom: 0px;">
You'll also be able to:</p>
<ul style="margin-top: 0px;">
<li class="style2">Request a mail ballot</li>
<li class="style2">Review/update your voter registration information</li>
<li class="style2">Check the status of your mail ballot</li>
<li class="style2">Review your voting activity for the past 12 months</li>
</ul>
<div id="NotRegistered" style="font-size: small;"><a href="https://www.voterfocus.com/ws/pfinder/printvapp4.php?county=lee" target="_blank">If you are not registered to vote please fill out our voter registration form</a></div><br>
<i><b style="text-decoration: underline;">All items are required</b></i>.
</div>
<div class="voterForm">
<div class="voterFormLine"><div>1.</div><div>Voter's Last Name</div><div><input title="Please enter your last name." id="NameID" type="text" size="10" maxlength="35" value=""></div>
</div><div class="voterFormLine"><div>2.</div><div>Voter's Birth Date</div><div><input title="Please enter your birth date (MM/DD/YYYY)." id="BirthDate" type="text" size="10" maxlength="10" value="">
<br>MM/DD/YYYY</div></div><div class="voterFormLine"><div>3.</div>
<div><a title="House Number" href="https://www.voterfocus.com/VFVoterGlossery.php?term=House Number" target="_blank">House Number</a> of Voter's Residence Address</div>
<div><input title="Please enter your house street number." id="StNumber" type="text" size="10" maxlength="10" value=""></div>
</div>
<div> </div>
</div>
<div><div style="text-align: center;"><h2 id="MoreVoter" style="display: none;"><b></b></h2>
<button id="ButtonForm" onclick="ButtonForm_onclick()" type="button" value="Submit">Submit</button></div>
</div>
</div>
VBA代碼:
'creates a new internet explorer window
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
'opens Lee County registration check
With IE
.Visible = True
.navigate "http://www.lee.vote/voters/check-your-registration-status/"
End With
'waits until IE is loaded
Do Until IE.ReadyState = 4 And Not IE.busy
DoEvents
Loop
'sends data to the webpage
Call IE.Document.getelementbyid("NameID").setattribute("value", Last_Name)
Call IE.Document.getelementbyid("BirthDate").setattribute("value", Date_of_Birth.Value)
Call IE.Document.getelementbyid("StNumber").setattribute("value", Street_Number.Value)
'"clicks" the button to display the results
IE.Document.getelementbyid("ButtonForm").Click
任何幫助嗎?
究竟不起作用?你可以做任何與網頁的互動或根本沒有? –
不是這個網頁。我無法將Access中的數據(字符串變量)傳遞到網頁上的表單字段。 – Dave
你可以與網頁互動嗎?例如從它讀取數據? –