With this vba-code :
If Not DishesDoc.getElementById("ContentPlaceHolder_LblRecetteTempsPrepa") Is Nothing Then
Failure = DishesDoc.getElementById("ContentPlaceHolder_LblRecetteTempsPrepa").innerText 'Failure being declared as an object
End If
I want to scrape data from this piece of HTML-code :
<ul class="borderSection_toolbar icon-prepa">
<li id="ContentPlaceHolder_trPrepa">Préparation
<span id="ContentPlaceHolder_LblRecetteTempsPrepa">15 min</span>
</li>
<li class="hide-for-small-only">
<button type="button" class="button dark border icon-step" data-stepper></button>
</li>
</ul>
Yet it produces a #91-error.
The code following this test gives the same error :
Debug.Print "Temps de préparation : " & Left(DishesDoc.getElementById("ContentPlaceHolder_LblRecetteTempsPrepa").innerText, Len(DishesDoc.getElementById("ContentPlaceHolder_LblRecetteTempsPrepa").innerText) - 4) & " minutes".
As this latter code works fine for most of the similar yet not identically coded pages, I want to avoid the code to crash on the differently coded pages.
PS: I tried to use the on error resume next and the on error goto errorhandler, but also these do not work.
How can I best solve these problems?
If Not DishesDoc.getElementById("ContentPlaceHolder_LblRecetteTempsPrepa") Is Nothing Then
Failure = DishesDoc.getElementById("ContentPlaceHolder_LblRecetteTempsPrepa").innerText 'Failure being declared as an object
End If
I want to scrape data from this piece of HTML-code :
<ul class="borderSection_toolbar icon-prepa">
<li id="ContentPlaceHolder_trPrepa">Préparation
<span id="ContentPlaceHolder_LblRecetteTempsPrepa">15 min</span>
</li>
<li class="hide-for-small-only">
<button type="button" class="button dark border icon-step" data-stepper></button>
</li>
</ul>
Yet it produces a #91-error.
The code following this test gives the same error :
Debug.Print "Temps de préparation : " & Left(DishesDoc.getElementById("ContentPlaceHolder_LblRecetteTempsPrepa").innerText, Len(DishesDoc.getElementById("ContentPlaceHolder_LblRecetteTempsPrepa").innerText) - 4) & " minutes".
As this latter code works fine for most of the similar yet not identically coded pages, I want to avoid the code to crash on the differently coded pages.
PS: I tried to use the on error resume next and the on error goto errorhandler, but also these do not work.
How can I best solve these problems?