0

这里有我的代码。我在需要检查空下拉列表的地方添加了一些备注。


Dim IE As Object Application.DisplayAlerts = False
Dim chromePath As String

     Set IE = CreateObject("InternetExplorer.application")
     IE.Navigate "https://www.facebook.com/"      
     IE.Visible = True

Dim doc As Object

     IE.Top = 0
     IE.Left = 0
     IE.Width = 1200
     IE.Height = 1000
     IE.AddressBar = 0
     IE.StatusBar = 0
     IE.Toolbar = 0
     IE.Visible = True
     With IE
          Do
               If IE.ReadyState = 4 Then
                    IE.Visible = True
                    Exit Do
               Else
                    DoEvents
               End If
          Loop
          DoEvents
          Application.Wait Now + TimeValue("00:00:05")
          IE.Document.getElementById("month").selectedIndex = -2
          '(Here i want to check if the selected dropdown is blank as in case
          'of month on facebook I want to show some error and also want to do
          'some more action) 'On Error GoTo Prob MsgBox "Code has completed"
          'Exit Sub
          'Prob: MsgBox Err.Description & " has prevented the code completing"
     End With
4

1 回答 1

0

If (IE.Document.getElementById("month").value = 0) Then
'or null, Empty, etc depending on element type (for combo it's 0th item)
     Call MsgBox ("The message box")
     'the other things you want to do
End If
于 2013-06-14T12:08:50.507 回答