如何暂停Excel VBA并在循环之前等待用户交互

我有一个非常基本的脚本,我正在使用Excel电子表格来填充表单。 它将数据插入到字段中,然后等待我单击每个页面上的提交button。 然后等待页面加载并填充下一组字段。 我点击提交,下一页加载等。最后,在最后两页,我必须做一些手动input,我不能用电子表格。 代码到目前为止如下所示。

我的问题是,在我现在有什么结束的时候,我怎样才能使系统等待我填写最后一页 ,然后一旦我提交它意识到它已经提交并循环回到开始,递增排在电子表格上,这样我们可以重新开始,为下一个学生再做整个事情?

正如你可能会告诉我,我不是一个程序员,只是一个音乐老师,谁不知道为我的200名学生手动填写这些forms的想法,并从教程中看到大部分的代码。


Function FillInternetForm() Dim IE As Object Set IE = CreateObject("InternetExplorer.Application") 'create new instance of IE. use reference to return current open IE if 'you want to use open IE window. Easiest way I know of is via title bar. IE.Navigate "https://account.makemusic.com/Account/Create/?ReturnUrl=/OpenId/VerifyGradebookRequest" 'go to web page listed inside quotes IE.Visible = True While IE.busy DoEvents 'wait until IE is done loading page. Wend IE.Document.All("BirthMonth").Value = "1" IE.Document.All("BirthYear").Value = "2000" IE.Document.All("Email").Value = ThisWorkbook.Sheets("queryRNstudents").Range("f2") IE.Document.All("Password").Value = ThisWorkbook.Sheets("queryRNstudents").Range("e2") IE.Document.All("PasswordConfirm").Value = ThisWorkbook.Sheets("queryRNstudents").Range("e2") IE.Document.All("Country").Value = "USA" IE.Document.All("responseButtonsDiv").Click newHour = Hour(Now()) newMinute = Minute(Now()) newSecond = Second(Now()) + 3 waitTime = TimeSerial(newHour, newMinute, newSecond) Application.Wait waitTime IE.Document.All("FirstName").Value = ThisWorkbook.Sheets("queryRNstudents").Range("a2") IE.Document.All("LastName").Value = ThisWorkbook.Sheets("queryRNstudents").Range("b2") IE.Document.All("Address1").Value = "123 Nowhere St" IE.Document.All("City").Value = "Des Moines" IE.Document.All("StateProvince").Value = "IA" IE.Document.All("ZipPostalCode").Value = "50318" End Function 

我会使用IE浏览器的事件,更具体的forms,像这样,使用MSHTML控件库。

 Private WithEvents IEForm As MSHTML.HTMLFormElement Public Sub InternetExplorerTest() Dim ie As SHDocVw.InternetExplorer Dim doc As MSHTML.HTMLDocument Set ie = New SHDocVw.InternetExplorer ie.Visible = 1 ie.navigate "http://stackoverflow.com/questions/tagged/vba" While ie.readyState <> READYSTATE_COMPLETE Or ie.Busy DoEvents Wend Set doc = ie.document Set IEForm = doc.forms(0) End Sub Private Function IEForm_onsubmit() As Boolean MsgBox "Form Submitted" End Function