• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

web automation thru vba

oodai

New Member
Hi I am looking for to automate current process where i take data from excel paste it in a web app once i get the results(hyper links) click on each link and take a screen print. I have tried with the below code which is not working

I am attaching the sample excel file, html code and steps

Code:
Option Explicit

Sub SubmitToWeb()
Dim rw As Long, ws As Worksheet
Dim IE As Object
Application.ScreenUpdating = False
   
    Set ws = Worksheets("Sheet2")
   
    Set IE = CreateObject("InternetExplorer.Application")
    IE.Visible = True
    IE.Navigate "https:XXXX"
   
    Application.StatusBar = "Submitting"

    ' Wait while IE loading...
    While IE.Busy
        DoEvents
    Wend
   
    For rw = 2 To ws.Range("A1").CurrentRegion.Rows.Count
        ' **********************************************************************
        delay 4
        IE.document.getElementById("ctl00_ManagedCompaniesComboBox").Value = ws.Range("A" & rw)
        delay 2
     Set ElementCol = IE.document.getelementsbytagname("a")

' loop through all 'input' elements and find the one with the value "Yes"

For Each elea In ElementCol
If InStr(elea.innerhtml, "MtxResource.asmx?r=Icons/Search.png") > 0 Then
elea.Click

Exit For

End If

Next
        delay 2
        IE.document.getElementById("_cb_Control_ctl00_MainContent_SearchWizard_SearchCriteriaStep_SearchCriteria_StoresComboBox").Value = ws.Range("B" & rw)
       
        ' How do i click on tranasaction search buttion
        delay 1
        IE.document.getElementById("_cb_Control_ctl00_MainContent_SearchWizard_SearchCriteriaStep_SearchCriteria_StoresComboBox").Value = ws.Range("C" & rw)
        delay 1
        IE.document.getElementById("ctl00$MainContent$SearchWizard$SearchCriteriaStep$SearchCriteria$AccountLast4TextBox").Value = ws.Range("D" & rw)
        delay 1
        IE.document.getElementById("ctl00$MainContent$SearchWizard$SearchCriteriaStep$SearchCriteria$SearchDates_TextBox").Value = ws.Range("E" & rw)
        delay 1
        IE.document.getElementById("ctl00$MainContent$SearchWizard$SearchCriteriaStep$SearchCriteria$AccountLast4TextBo").Value = ws.Range("E" & rw)
        delay 1
        IE.document.getElementById("ctl00$MainContent$SearchWizard$SearchCriteriaStep$SearchCriteria$SearchTransactionsButton").Click
        '**********************************************************************
    Next rw
   
    Application.StatusBar = "Form Submitted"
    IE.Quit
    Set IE = Nothing

    Application.ScreenUpdating = True
End Sub

Private Sub delay(seconds As Long)
    Dim endTime As Date
    endTime = DateAdd("s", seconds, Now())
    Do While Now() < endTime
        DoEvents
    Loop
End Sub
 

Attachments

  • retrieval - Copy.xlsm
    17.3 KB · Views: 2
  • Source code.txt
    3.2 KB · Views: 3
  • screen print.docx
    65.3 KB · Views: 1

Hi,

many ways to click on a element, depends on the webpage itself …
All I can say without any URL …

Use your webbrowser inspector tool.
You could read href property from a tags …
 
Back
Top