title: Select Drop Down from Web Page with IE object
body: <p>Have the below code for a drop down selection in VBA .</p>
  
  <p>When I run this I get the error on the bold line saying "Runtime error 91 - Object variable or with block variable not set " ..New to VBA ....</p>
  
  <pre><code>Sub NACDP()
  ' open IE, navigate to the desired page and loop until fully loaded
      Set ie = CreateObject("InternetExplorer.Application")
      my_url = "https://cdeployna.cognizant.com/"
  
      With ie
          .Visible = True
          .Navigate my_url
          .Top = 50
          .Left = 530
          .Height = 400
          .Width = 400
  
      Do Until Not ie.Busy And ie.readyState = 4
          DoEvents
      Loop
  
      End With
  
  ' Input the userid and password
      ie.Document.getElementById("loginControl_UserName").Value = ""
      ie.Document.getElementById("loginControl_Password").Value = ""
  
  ' Click the "Login" button
      ie.Document.getElementById("loginControl_LoginButton").Click
  
      Do Until Not ie.Busy And ie.readyState = 4
          DoEvents
      Loop
  
      ie.Document.getElementById("ctl00_ddlRoles").selectedindex = 1
      ie.Document.getElementById("ctl00_ddlRoles").FireEvent ("onchange")
  
       Do Until Not ie.Busy And ie.readyState = 4
          DoEvents
      Loop
  
      ie.Document.getElementById("ctl00_ContentBody_searchCDPList_ddlFieldName").selectedindex = 1
      ie.Document.getElementById("ctl00_ContentBody_searchCDPList_ddlFieldName").FireEvent ("onchange")
      ie.Document.getElementById("ctl00_ContentBody_searchCDPList_txtValue").Value = "Java"
  
      ' Click the "Search" button
  
      ie.Document.getElementById("ctl00_ContentBody_searchCDPList_btnSearch").Click
  
  
  End Sub
  </code></pre>