• 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.

VBA-Select Nth item from Web Page Drop Down-Select by it's position in list

asleepdirka

New Member
Hello,

Any assistance with the following VBA code is greatly appreciated!


Task:


1. I use an excel macro to open internet explorer and Log In to my intranet company website (already done), I need to select the second item in the first, of 2, drop down boxes. The name in the dropdown list will be different each time I login, but it will remain the 2nd option in the list.


2. Once selected, an excel message box appears asking to Open or Save the excel report (connected to the dropdown selection). I would like to Open this file


3. Because the files name is different each time I open it, I would like to Save As a standard name, lets say, “myexcelfile” in a standard folder, lets say, “C:DocumentsExcelFiles” which overwrites any existing file of that same name.


_______________________Web Page Source Code for Drop Down List____________________________


'I need to select the second option value below(1234variable-name.xls), which is the first selectable item in the list.


<option value=” (Select a report) ”> (Select a report) </option>


<option value=”/MyCompanyDept/CompanyFile/MyCompanyDept/Reports/1234variable-name.xls” title=”4/10/2013 - My Company - ReportName”>4/10/2013 - My Company - Report Name</option>


<option value=”/MyCompanyDept/CompanyFile/MyCompanyDept/Reports/do not need this one.xls” title=”4/10/2013 - My Company – ReportName2”>4/10/2013 - My Company - Report Name2</option>


I was thinking there must be a way to select using an index; 2nd item in list, or something similar. I'm Not sure about saving the variably named .xls file once opened, if the macro file to run the VBA has been opened first. As well, I won't know the name of the dropdown.xls file from the webpage.

Thank you for your time and any assistance you may provide,

John
 
I should add that the following code exits before and after the option values post above:


<div class= "Content">

<select name="ct100 style="width:220px; ">


'Drop Down Options are listed here...


</select> <input type="button" id="btnGo" name="btnGo" value="Go" class="SmallButton"

onclick="viewReport()" />

</div>


Thanks again!
 
I may not be able to do that due to company restrictions, but I'll try. Either way, in order to access the excel file, I have to select the 2nd item in the list for the excel message box to appear; "Open or Save File". I thought there may be a way to call the item by it's position in the list [EG: ie.Document.All.Item(2).Selected=True] or something like that.

Thanks Narayan
 
Unfortunately not able to try your suggestion Narayan. At this point, I would be happy just to get the drop down item selected.

Thanks for looking at it though!
 
Hi, asleepdirka!

Consider uploading a sample file (including printscreens of the website pages), it'd be very useful for those who read this and might be able to help you. Thank you.

Give a look at the green sticky posts at this forums main page for uploading guidelines.

Regards!
 
The website I am working on is a company intranet page, which contains highly sensitive information and anything exported would be blocked by our web marshall; sorry I can't provide more detailed information. There are only two drop down lists on the page and when you click on my item you get a msgbox prompting to open or save the excel report associated with that list item.


The following is the Web Page View Source HTML code:


_____________________Web Page Source Code for Drop Down List____________________________


'I need to select the second option value below(1234variable-name.xls), which is the first selectable item in the list.


<option value=” (Select a report) ”> (Select a report) </option>


<option value=”/MyCompanyDept/CompanyFile/MyCompanyDept/Reports/1234variable-name.xls” title=”4/10/2013 - My Company - ReportName”>4/10/2013 - My Company - Report Name</option>


<option value=”/MyCompanyDept/CompanyFile/MyCompanyDept/Reports/do not need this one.xls” title=”4/10/2013 - My Company – ReportName2”>4/10/2013 - My Company - Report Name2</option>


THX
 
Hi, asleepdirka!


You've crossposted this topic here:

http://chandoo.org/forums/topic/vbaselect-webpage-drop-down?replies=2#post-95556


As I quoted in that topic, you shouldn't do it, in the rules topic it explained what to do and how to behave in the community.


Regarding your unanswered question in this topic, maybe the information you provided (3 lines instead of a workbook and the link to a webpage) have been insufficient to people who might have read this -because I can assure that many people read all the topics, including this, including myself-. If I suppose correctly they hadn't the elements to fully understand your issue and that's why you didn't receive any answer.


Opening a new topic not only doesn't guarantees you to get a response but a contrario sensu you'd get the opposite result.


If after a reasonable time you don't get any solution, well, write again in the same post so as to maintain the thread: the effect of bringing your topic to the top pages will be equally achieved.


Regards!
 
Back
Top