Consulting

Results 1 to 2 of 2

Thread: VBA to select multiple web pages

  1. #1
    VBAX Contributor
    Joined
    Oct 2013
    Posts
    181
    Location

    VBA to select multiple web pages

    I am trying to use the HTML and VBA code below to login and select multiple buttons and links but I do not know VBA with HTML code. I got the VBA login part to work but I cannot navigate to the next page which is “Shipping Services” button. Does anyone know if the below code will work and how to make the below code navigate to the “Shipping Services” page.

    Thank you for any and all help.

    HTML Code:
    <div class="vtabs-tab-column">            <ul class="tabs-slider">            <li class="closed" id="url_v_menu_item_1">                <a class="closed" id="url_v_menu_item_1"                     href="/eAdmin/action/homepage" title="Welcome" tabindex="21">                        Welcome                 </a>            </li>            <li class="closed" id="url_v_menu_item_2">                                        <a class="closed" id="a_v_menu_item_2"                    href="/eAdmin/action/inbox" title="Inbox" tabindex="22">                    Inbox                 </a>            </li>            <li class="closed" id="url_v_menu_item_3">                <a class="closed" id="a_v_menu_item_3"                    href="/eAdmin/action/addservice/mailingServices" title="Mailing Services" tabindex="23">                        Mailing Services                 </a>            </li>            <li class="closed" id="url_v_menu_item_4">                <a class="closed" id="a_v_menu_item_4"                    href="/eAdmin/action/addservice/shippingServices" title="Shipping Services" tabindex="24">                        Shipping Services                </a>            </li>
    Option Explicit
    Sub MyGmail()
    Dim htmlDoc As HTMLDocument
    Dim MyBrowser As InternetExplorer
    Dim MyHTML_Element As IHTMLElement
    Dim MyURL As String
    Dim ULogin As Boolean, ieForm
    On Error GoTo Err_Clear
    MyURL = "https://gateway.usps.com/eAdmin/view/signin"
    Set MyBrowser = New InternetExplorer
    MyBrowser.Silent = True
    MyBrowser.navigate MyURL
    MyBrowser.Visible = True
    Do
    Loop Until MyBrowser.readyState = READYSTATE_COMPLETE
    Set htmlDoc = MyBrowser.document
    htmlDoc.all.UserName.Value = "Login" 'Enter your id here
    htmlDoc.all.Password.Value = "Password" 'Enter your password here
    For Each MyHTML_Element In htmlDoc.getElementsByTagName("input")
    If MyHTML_Element.Type = "button" Then MyHTML_Element.Click: Exit For
    Next
     
    With MyBrowser.document
     
        For Each MyHTML_Element In htmlDoc.getElementsByClassName("closed") 'TagName("input")
     
            If (MyHTML_Element.getAttribute("href") = "/eAdmin/action/addservice/shippingServices") Then
                MyHTML_Element.Click
                Exit For
            End If
       
        Next MyHTML_Element
     
    End With
     
    Err_Clear:
    If Err <> 0 Then
    Err.Clear
    Resume Next
    End If
    End Sub

  2. #2
    VBAX Contributor
    Joined
    Oct 2013
    Posts
    181
    Location

    VBA to select multiple web pages

    Can read the HTML code better this way. I am trying to select "Shipping Services" below.

    <div class="vtabs-tab-column">            <ul class="tabs-slider">
                <li class="closed" id="url_v_menu_item_1">
                    <a class="closed" id="url_v_menu_item_1" 
                        href="/eAdmin/action/homepage" title="Welcome" tabindex="21">
                            Welcome 
                    </a>
                </li>
                <li class="closed" id="url_v_menu_item_2">                        
                    <a class="closed" id="a_v_menu_item_2"
                        href="/eAdmin/action/inbox" title="Inbox" tabindex="22">
                        Inbox
                     </a>
                </li>
                <li class="closed" id="url_v_menu_item_3">
                    <a class="closed" id="a_v_menu_item_3"
                        href="/eAdmin/action/addservice/mailingServices" title="Mailing Services" tabindex="23">
                            Mailing Services 
                    </a>
                </li>
                 <li class="closed" id="url_v_menu_item_4">
                    <a class="closed" id="a_v_menu_item_4"
                        href="/eAdmin/action/addservice/shippingServices" title="Shipping Services" tabindex="24">
                            Shipping Services
                    </a>
                </li>
                <li class="closed" id="url_v_menu_item_6">
                    <a class="closed" id="a_v_menu_item_6"
                        href="/eAdmin/action/addservice/otherServices" title="Other Services" tabindex="26">
                            Other Services
                    </a>
                </li>
                <li class="closed" id="url_v_menu_item_7">
                    <a class="closed" id="a_v_menu_item_7"
                        href="/eAdmin/action/resources/support" title="Support" tabindex="27">
                            Support
                    </a>
                </li>
                <li class="closed" id="url_v_menu_item_8">
                    <a class="closed" id="a_v_menu_item_8"
                        href="/eAdmin/action/preferences" title="Manage Account" tabindex="28">
                            Manage Account 
                    </a>
                </li>
                </ul>
            </div>

Posting Permissions

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