Welcome to the fracta.net forum!

Share your coding ideas or ask questions.

Question How to click the list item in web IE application with VBA

  • psaroha
  • Topic Author
  • Visitor
  • Visitor
5 years 11 months ago #661 by psaroha
Basically my requirement is to download the excel file from webpage through vba. I have written the code to login but unable to click on the list item. I need to iterate the loop through class and then list and tag a. So help me how can iterate through multiple option with vba.

<ul>

class="secondaryList" id="scheduledReportList">


<li>
<a title="Polycom Hourly (Intraday)" class="reportSelection" href="reportAction.do?schRptOid=8a85913f61a0bb410162881d808c0266">Polycom Hourly (Intraday)</a></li>


li><a title="Polycom Hourly Report (Intraday)" class="reportSelection" href="reportAction.do?schRptOid=8a85913f62c9be2f0162f2eaffae004e">Polycom Hourly Report (Intraday)</a>
</li>


<li>
<a title="TU - Polycom (Time Utilization)" class="reportSelection" href="reportAction.do?schRptOid=8a85913f61a0be6c0162ab751ae902f9">TU - Polycom (Time Utilization)</a>
</li>

</ul>

Please Log in or Create an account to join the conversation.

More
5 years 11 months ago #662 by roller
I am not sure if I understand the question but it seems like you want to select an item from the list then generate the report for the selected item. If this is correct and you know which item you want why not bypass the list and it's items. Simply get VBA to call the webpage related to the item you want - no need to select it.

From what I can see each item is a reference to a URL, so from VBA call the URL directly by using thewebdomainxxx.com/reportAction.do?schR...be6c0162ab751ae902f9

Please Log in or Create an account to join the conversation.

  • psaroha
  • Topic Author
  • Visitor
  • Visitor
5 years 11 months ago #663 by psaroha
its not web page. Once i click the title="Polycom Hourly (Intraday)" then it will give start date and end date parameter and then need to click on the generate button.

Please Log in or Create an account to join the conversation.

More
5 years 11 months ago #664 by roller
If you are interacting with the interface using a browser then the final call will be a call to URL using a GET or POST method. Basically all the parameters will be loaded into a URL call. I can't tell you what it is because I can't see it. You should be examining the traffic out of the browser to work out how to make the call using the specially crafted URL. Anyway this is the approach I would be looking at.

But if you want to play around using your approach I can tell you roughly from the top of my head what the VBA might look like. However you haven't posted any of your code and I guess I can't access the site to see what you are talking about! You are expecting someone to do the work for you without making or showing what you have attempted.

Anyway I will point you in a direction and you work it out yourself. The VBA might be something like:

Dim IE As InternetExplorer
Set IE = New InternetExplorer
IE.Visible = True
IE.Navigate " www.website.com "
Do Until IE.ReadyState >= 4
DoEvents
Loop
IE.Document.getElementsByName("theName??")(0).Focus
then if you know what to choose
IE.Document.getElementsByName("theName??")(0).Value = "SYDNEY"
or maybe if to select an item
IE.Document.getElementsByName("location")(0).Item(1).Selected = True
then if a button needs to be clicked
IE.Document.getElementsByName("buttonID")(0).Click

to loop you can use ...items.count perhaps to get how many in the list and use a FOR loop to iterate.

Or perhaps use for each ....item in ... items to iterate through the list.

this is just of the top of my head, not sure of the exact coding for the website you are using. Good luck. If you happen to work it out you are welcome to post your solution for other future reference.

Please Log in or Create an account to join the conversation.

More
5 years 11 months ago #665 by roller
Did you say Polycomm? check my video
is this what you have, the same type of phone?

Please Log in or Create an account to join the conversation.

  • psaroha
  • Topic Author
  • Visitor
  • Visitor
5 years 11 months ago #666 by psaroha

File Attachment:

File Name: Capture.zip
File Size:230 KB

Hey, thanks for you example post.
Here is my code.
Adding the screen shot to make clear that highlighted hourly report need to click with vba.

If you need more to understand the requirement please let me know.

Sub DownloadIntraDayReport()
Dim ie As New InternetExplorer
ie.navigate "web link"
ie.Visible = True
While ie.Busy
DoEvents
Wend
Do
Loop Until ie.readyState = READYSTATE_COMPLETE
Set HTMLDoc = ie.document
ie.document.getElementById("_58_login").Value = "username"
ie.document.getElementById("_58_password").Value = "password"
'ie.document.form().submit
For Each MyHTML_Element In HTMLDoc.getElementsByTagName("input")
If MyHTML_Element.Type = "submit" Then MyHTML_Element.Click
Next

#code is working fine till login. But need to click on list item for next step it did not response me.#

ie.document.querySelector("#scheduledReportList > li > a").Click

End Sub
Attachments:

Please Log in or Create an account to join the conversation.

Time to create page: 0.524 seconds
Powered by Kunena Forum