我打開一個使用VBA代碼的網頁,其中包含將由用戶填充數據的表單。我有excel包含數據的文件。我寫的VBA代碼,從Excel中讀取數據並將其放在網頁上。在填寫網頁信息後,我點擊保存按鈕。我使用VBA代碼完成了所有這些工作,以便它可以自動完成。我有500個用戶數據,因此我運行循環500次。所有罰款。使用VBA代碼禁用網頁的提醒消息
只有一個問題來了,就是當我點擊保存按鈕彈出消息「你的數據保存成功」,網頁表格填寫數據後。它有「確定」按鈕。現在我的程序停在這裏,需要用戶干預才能手動點擊「確定」按鈕。
有沒有什麼辦法使用VBA代碼,通過它我們可以停止彈出消息框,以便不再需要手動干預?
我讀了網頁和爲網頁編寫的Javascript。我發現當保存按鈕被點擊一個叫做savedetails()
的函數。在這個函數裏面有一個alert()
函數。示例代碼這裏
function saveDetails()
{
/* get details of member*/
---
---
---
---
---
if (xml.status == 200 || window.location.href.indexOf("http") == -1) {
var successCode = "";
alert("Data Saved Successfully");
var tes = xml.responseText;
/* if (successCode == '1') { */
document.webDataForm.submit();
remove_popup();
};
}
VBA代碼對於每個htmlInput在htmlColl
If Trim(htmlInput.ID) = "btn" Then
If Trim(htmlInput.Name) = "btnfinal" Then
htmlInput.Click 'After this "Data Saved Successfully popup message comes and program need user intervention
temp = htmlInput.getAttribute("onClick")
MsgBox temp
'IE.document.getElementById("clearRelItems").removeAttribute ("o n C l i c k")
'Call iedoc.parentWindow.execScript("window.confirm = function saveBankDetails() {return true}", "JavaScript") // Not worked
'htmlInput.removeAttribute ("onClick") //Not worked
'htmlInput.setAttribute "onClick", "return TRUE" //Not worked
'Application.SendKeys "{ENTER}", True // Not worked
Exit For
End If
End If
Next htmlInput
我想了解您的問題......是否希望「數據保存成功」警報消息顯示,但在一兩分鐘後自動關閉自身(因此不需要確定按鈕)?或者您要求沒有顯示「數據保存成功」警報消息?因爲如果它是後者(根本沒有消息),那麼只需在代碼中刪除'alert(「Data Saved Successfully」)''行。 – cybermike 2015-03-25 12:01:17