1
我想在excel VBA中使用一些Internet Explorer自動化。當用戶按下按鈕時,他被帶到gmail,他必須在那裏驗證自己。認證之後,他可以將數據發佈到Web服務。這裏是我的代碼從excel VBA驗證
Dim AppUrl As String
AppUrl = "https://mail.google.com"
Call NavigateToURL(AppUrl)
Public Sub NavigateToURL(argURL)
Dim LoginURL As String
Dim ServiceUrl As String
Dim objIE As Object
Dim URl As String
LoginURL = "https://mail.google.com/mail/u/0/#inbox"
Set objIE = CreateObject("InternetExplorer.Application")
With objIE
.Visible = True
.Silent = False
.Navigate argURL
While IE.Busy
DoEvents
Wend
Do
If objIE.LocationURL()= LoginURL Then
MsgBox("Successfully Authenticated")
Call requestPost 'to post excel data to a webservice
Exit Do
Else
MsgBox("Authentication failed")
End If
Loop While objIE.LocationURL() <> (LoginURL)
End With
End Sub
但我面臨的問題是,一旦https://mail.google.com負荷完全,如果條件檢查,並顯示失敗的消息認證。我想要程序等到https://mail.google.com/mail/u/0/#inbox加載。有沒有辦法做到這一點?