+ Reply to Thread
Results 1 to 2 of 2

VBA Code to Check Multiple Checkboxes in HTML

  1. #1
    Registered User
    Join Date
    02-18-2019
    Location
    United States
    MS-Off Ver
    Office 365
    Posts
    11

    VBA Code to Check Multiple Checkboxes in HTML

    Bump. Please Help.
    Last edited by Beast_OnThe_Keys; 09-18-2019 at 09:28 AM.

  2. #2
    Registered User
    Join Date
    02-18-2019
    Location
    United States
    MS-Off Ver
    Office 365
    Posts
    11

    Re: VBA Code to Check Multiple Checkboxes in HTML

    Good Afternoon Folks!

    Here again with a problem that has been frustrating me for the last 12 hours.

    I am writing some VBA that allows me to automatically log in to a password protected site, navigate me to a table, pop into a data toggle tab, select multiple check boxes, searches results, copy and pastes them from HTMi table to worksheet.

    Currently my code successfully;

    1. Logs me in
    2. Navigates me to table
    3. Pops into data toggle tab (where multiple check boxes are for additional criteria you would like to add)
    4. Checks one box (the first element i reference)

    Then i get a runtime error saying Object required.

    I guess my question for now is how do I reference another element check box to be ".Clicked"?

    Code Below

    Sub ImportData()

    Dim ie As Object
    Dim objCollection As Object
    Set ie = CreateObject("internetexplorer.application")
    With ie
    ie.Visible = True
    ie.Navigate "WEBPAGE"

    Do While .Busy
    DoEvents
    Loop

    Do While .ReadyState <> 4
    DoEvents
    Loop

    End With

    Set Email = ie.Document.getElementById("ELEMENT ID")
    Email.Value = "john@examplecom"

    Set Password = ie.Document.getElementById("ELEMENT ID")
    Password.Value = "PASSWORD"

    Set submit = ie.Document.getElementById("ELEMENT ID")
    submit.Click

    With ie
    .Navigate "WEBPAGE"
    Do While .Busy
    DoEvents
    Loop
    Do While .ReadyState <> 4
    DoEvents
    Loop
    End With

    ie.Visible = True
    Set Doc = ie.Document

    Dim links, link

    Dim j As Integer
    j = 0
    Set links = ie.Document.getElementById("SET ELEMENT ID LINK").getElementsByTagName("a")
    n = links.Length
    While j <= n
    links(j).Click
    While ie.Busy
    DoEvents
    Wend

    ie.Document.getElementById("ELEMENT ID CHECKBOX 1").Click
    Do While ie.Busy
    DoEvents
    Loop
    Set links = ie.Document.getElementById("SET ELEMENT ID LINK").getelementsbytagname("a")
    j = j + 2

    My code works up until here. The second element checkbox I need to have clicked is below but again getting Object Required run time error

    Wend
    ie.Document.getElementById("ELEMENT ID CHECKBOX 2").Click
    Do While ie.Busy
    DoEvents
    Loop
    Set links = ie.Document.getElementById("SET ELEMENT ID LINK").getelementsbytagname("a")
    j = j + 2
    End Sub


    I have about 7-8 uniquely named elements, or check boxes, or both (or whatever they are defined as, I am new to VBA) that I need to have selected before I hit the submit button and update the table. Thought I could nest them kinda like an IF statement but guess not. I haven't even started looking at the copy and paste to workbook/sheet function so any pointers going into that would be greatly appreciated if this is an easy fix.

    I greatly appreciate your time,

    Cheers!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Checkboxes - How to check/uncheck other checkboxes based on another checkbox
    By brooklyn_87 in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 10-27-2017, 01:20 PM
  2. Macro code to check if all checkboxes on userform are false
    By WilliamWu in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-01-2013, 03:33 PM
  3. [SOLVED] Please help! macro code needed to assign to command button to check a column of checkboxes
    By cnbv in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-22-2013, 04:47 AM
  4. [SOLVED] multiple checkboxes macro check/uncheck
    By SHELTONUNDERDOG in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-07-2012, 01:36 PM
  5. Help With VBA Code Using Multiple Checkboxes
    By NALynch in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-11-2012, 02:50 AM
  6. vba code/macro to check checkboxes
    By Jzon758 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-02-2012, 02:55 PM
  7. [SOLVED] VBA code - unable to check checkboxes (userform) in Excel 2010
    By mat418pic in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-23-2012, 02:59 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1