I am trying to check a checkbox on a web page using Excel VBA. My code did not work. (There was no error but the tick was ticked)
How can I make the tick show when I do it on the web page?
Am I doing something wrong with the web scraping?
HTML:
<div class="slick-header ui-state-default">
<div class="slick-header-columns ui-sortable" style="left: -1000px;" unselectable="on">
<div title="Sélectionner / désélectionner tout" class="ui-state-default slick-header-column" id="slickgrid_951473vssGrid_rowSelect_123527" style="width: 21px;">
<div class="header">
<input type="checkbox">
</div>
</div>
<div class="ui-state-default slick-header-column" id="slickgrid_951473purchase_order" style="width: 104px;">
<div class="header slick-sort-header"><span class="slick-column-name">Bon de commande</span></div><span class="slick-sort-indicator"></span>
<div class="slick-resizable-handle"></div>
</div>
<div class="ui-state-default slick-header-column" id="slickgrid_951473purchase_order_date" style="width: 104px;">
<div class="header slick-sort-header"><span class="slick-column-name">Date de la commande</span></div><span class="slick-sort-indicator slick-sort-indicator-asc"></span>
<div class="slick-resizable-handle"></div>
</div>
<div class="ui-state-default slick-header-column" id="slickgrid_951473latest_ship_date" style="width: 103px;">
<div class="header slick-sort-header"><span class="slick-column-name">Date d'expédition maximale</span></div><span class="slick-sort-indicator"></span>
<div class="slick-resizable-handle"></div>
</div>
<div class="ui-state-default slick-header-column" id="slickgrid_951473vendor_code" style="width: 103px;">
<div class="header slick-sort-header"><span class="slick-column-name">Vendor code</span></div><span class="slick-sort-indicator"></span>
<div class="slick-resizable-handle"></div>
</div>
<div class="ui-state-default slick-header-column" id="slickgrid_951473payee_code" style="width: 103px;">
<div class="header slick-sort-header"><span class="slick-column-name">Code bénéficiaire</span></div><span class="slick-sort-indicator"></span>
<div class="slick-resizable-handle"></div>
</div>
<div class="ui-state-default slick-header-column" id="slickgrid_951473warehouse_id" style="width: 103px;">
<div class="header slick-sort-header"><span class="slick-column-name">Entrepôt de destination</span></div><span class="slick-sort-indicator"></span>
<div class="slick-resizable-handle"></div>
</div>
<div class="ui-state-default slick-header-column" id="slickgrid_951473currency_code" style="width: 103px;">
<div class="header slick-sort-header"><span class="slick-column-name">Devise</span></div><span class="slick-sort-indicator"></span>
<div class="slick-resizable-handle"></div>
</div>
<div class="ui-state-default slick-header-column" id="slickgrid_951473status" style="width: 103px;">
<div class="header slick-sort-header"><span class="slick-column-name">Statut</span></div><span class="slick-sort-indicator"></span></div>
</div>
</div>
VBA code :
Sub automationAmazon()
Dim ie As Object
Set ie = CreateObject("internetexplorer.application")
With ie
.Visible = True
.navigate "link"
Do While .busy
DoEvents
Loop
Do While .readyState <> 4
DoEvents
Loop
End With
Set Email = ie.document.getelementbyid("ap_email")
Email.Value = "[email protected]"
Set Password = ie.document.getelementbyid("ap_password")
Password.Value = "xxx"
Set submit = ie.document.getelementbyid("signInSubmit")
submit.Click
With ie
.navigate "link"
Do While .busy
DoEvents
Loop
Do While .readyState <> 4
DoEvents
Loop
End With
ie.document.all("searchBy").Value = "PURCHASE_ORDER"
ie.document.all("purchaseOrderNumber").Value = ThisWorkbook.Sheets("Data").Cells(1, 2).Text
ie.document.getelementbyid("create-invoice-search-submit").Click
Dim cBox As Object
Set cBox = ie.document.getElementsByClassName("header")(0)
cBox.Click
End Sub
The HTML: