Using Access 2007 to automate Internet Explorer issue with drop down box selection

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JMANTN
    New Member
    • Apr 2010
    • 8

    Using Access 2007 to automate Internet Explorer issue with drop down box selection

    I have data that sometimes needs to be uploaded to a 3rd party website and I’m trying to automate this process with Access 2007. I’m having a difficult time with my VBA syntax and with identifying the HTML names/id’s of objects I want to control.

    I have referenced Microsoft HTML Object Library & Microsoft Internet Controls and should note the version of Internet Explorer my company currently uses is IE6 (I know can’t wait for an update)

    Here is my current code:

    Code:
    Private Sub Testing17_Click()
    
    On Error Resume Next
    
    Dim IE As Object
    Dim document, element
    Dim btn As HTMLButtonElement
    
    Set IE = CreateObject("internetexplorer.application")
    
    IE.Navigate "https://www.quickbase.com/db/bc68fkzzg?a=ImportExport"
    IE.Visible = True
    
    While IE.busy
    DoEvents
    Wend
    
    For Each btn In IE.document.all.tags("Input")
    If btn.Value = "ImportClipboard" Then
    Call btn.Click
    End If
    Next btn
    
    While IE.busy
    DoEvents
    Wend
    
    End Sub
    The code above simply opens an instance of IE and navigates to the site (it does have a log in I think but I have my browser set to auto login) and selects a radio button for the Option ImportClipboard however there is a drop down box in which I need to select Reservations and this is the point I'm stuck at. I don't know the proper syntax to use and I tried using the above code with variations such as:

    Code:
    For Each btn In IE.document.all.tags("Select")
    If btn.Value = "Reservations" Then
    Call btn.Click
    End If
    Next btn
    But nothing happens (and no error messages). I'm wondering if I should be using a click for the dropdown selection as well.

    I’ve followed the instructions from this site (http://www.tek-tips.com/faqs.cfm?fid=6399) and pasted into excel and will include in an attachment (I’ve highlighted the row in green that I think has the pertinent info). I've also attached some of the HTML from the site on the additional pages if that helps.

    Also any reference sites/links anyone can suggest that a beginner could follow I'd appreciate it as I've found several similar issues for excel but nothing specific for dropdown boxes or a list of Internet Controls for Access.
  • JMANTN
    New Member
    • Apr 2010
    • 8

    #2
    Hate to reply to my own thread but in case anyone else comes across this figured I'd show the code that worked for me which took me two days and a lot of trial and error...



    Code:
    Private Sub Testing17_Click()
    
    On Error Resume Next
    
    Dim IE As Object
    Dim document, element
    Dim btn As HTMLButtonElement
    
    Set IE = CreateObject("internetexplorer.application")
    
    IE.Navigate "https://www.quickbase.com/db/bc68fkzzg?a=ImportExport"
    IE.Visible = True
    
    While IE.Busy
    DoEvents
    Wend
    
    
    For Each btn In IE.document.all.tags("Input")
    If btn.Value = "ImportClipboard" Then
    Call btn.Click
    End If
    Next btn
    
    While IE.Busy
    DoEvents
    Wend
    
    'This is what selects the table and then the element in the drop down/combo box
    IE.document.all.Item("table").Value = "bc68fkzzi"  
    
    Set IE = Nothing
    
    End Sub

    Comment

    Working...