No element ID or Name

MrToolman

New Member
Joined
Feb 23, 2018
Messages
3
Hi Everyone,

First time poster here although I've been referencing many posts from this forum for years. So much great info here.

I'm trying to submit package info to the UPS site to automatically return the shipping rates. For a single package I'm able to do it. When trying to set up for multiple packages I got jammed up and can't figure this out. Hopefully someone can help.

Below you can see the 'inspect element' code for the First, Previous, Next, and Last button options.

Code:
<button *******="PackageDetailJS.moveToFirst(3, packageDetailInputForm); return false;"><<</button>
<button *******="PackageDetailJS.moveToPrevious(3, packageDetailInputForm); return false;">< Prev</button>
<button class="next" *******="PackageDetailJS.moveToNext(3, packageDetailInputForm); return false;">Next ></button>
<button class="next" *******="PackageDetailJS.moveToLast(3, packageDetailInputForm); return false;">>></button>

So far I've been referencing elements using the 'Name' or 'ID' fields, but this doesn't have any. So, how do I reference and click the "Next" button?

Thanks ahead of time for any help with this.
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Sorry, the code displayed the button itself and I couldn't find the Edit Post button. Here's the code below (minus the <button___ button=""><button and /button>)

Code:
class="next" *******="PackageDetailJS.moveToNext(3, packageDetailInputForm); return false;">Next >

The "3" represents the next page or entry number I'm attempting to move to. I already manually entered data in the first two.</button___>
 
Upvote 0
I'm sorry for my first two posts not coming out correctly. Apparently I'm not allowed to edit my own posts as a new member and I don't see a preview button in the reply options.

Hopefully this image will clarify what I'm working with here.


zCnZU3a.jpg


How do I tell VBA to click the next button?
 
Upvote 0
Try this to find and click the 'Next >' button. Requires reference to MS HTML library.
Code:
    Dim IE As Object
    Dim HTMLdoc As HTMLDocument
    Dim buttons As IHTMLElementCollection, nextButton As HTMLButtonElement, i As Long
    Set HTMLdoc = IE.document  'IE is your InternetExplorer object with the page loaded
    Set buttons = HTMLdoc.getElementsByTagName("button")
    Set nextButton = Nothing
    While i < buttons.Length And nextButton Is Nothing
        If buttons(i).innerText = "Next >" Then Set nextButton = buttons(i)
        i = i + 1
    Wend
    If Not nextButton Is Nothing Then
        nextButton.Click
    Else
        MsgBox "Next > button not found"
    End If
 
Upvote 0

Forum statistics

Threads
1,215,377
Messages
6,124,598
Members
449,174
Latest member
chandan4057

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top