Changing option value in dropdown item using excel vba - excel

I am new learner to programming and new to excel-VBA as well and learning scraping through it. I am trying to programmatically change the color on a website having below html
<div><select id="Color" name="Color" data-dojo- type="dijit.form.FilteringSelect"><option value="ORANGE">Orange</option><option value="GREEN" selected="selected">Green</option><option value="YELLOW">Yellow</option></select></div>
IE1.document.getElementByID("Color").Value = "Orange"
IE1.document.getElementByID("Color").Focus
IE1.document.getElementByID("Color").Click
After doing this I can see the "Orange" being written on the dropdown on webpage but when I submit the form on website then it considers the default selected "Green" value and not the changed value which is "Orange". Also tried focus and click but still no luck.
Could you please help me out here? I tried searching for any existing VBA solution but could not find any. I think dijit.form.FilteringSelect is what it is making it unique.

You will have to change the value using dijit tools.
The first command grabs the widget from dojo's widget registry.
They second command changes it.
var fs = dijit.registry.byId("Color");
fs.set("value","Orange");

Related

Combo Box not showing on Excel VBA Form

I have a form with multiple Combo boxes. I was doing some appearance tweaking of the form and one of the boxes is not showing anywhere. If I try to add a new combobox with the same name it says it is not unique.
I tried Opening the form with a message in the box "Here I am" but it did not show. I don't get any compile errors as there are multiple references to the field in my code. Is there anyway to find it (Me.cmb_Photographer)?
It could be a bunch of different things. Perhaps the visible property is set to No or the control is behind another control. You might also have mislabeled something so Name property is different from the Control Source property.
In any case you should be able to go into design mode, open the property sheet and use the dropdown to find the control you're looking for. It should highlight the control on the form.

Clicking checkbox on an intranet web page not working in VBA using Internet Explorer 11

I am stuck at a specific point in coding VBA. Using VBA I am logging onto an Intranet portal which is a file management system and opening a series of dynamic web pages one after the other. Using VBA I am trying to get a checkbox element checked. Once this element is checked, all sub-elements appearing in a table below get checked automatically. After this I need to initiate download of all the selected files. However, I cannot get the checkbox element "checked".
Here is the HTML as it appears on the web-page. I cannot share the link as it is intranet and confidential.
Link to the HTML as I am not allowed to post images yet
Here is my VBA code:
Set inpute = objIE.Document.queryselector("div[id=gridx_Grid_2] div div div table tbody tr td span[aria-checked=false]")
inpute.setAttribute("aria-checked") = True
inpute.Click
When the above code is run, the "aria-selected" attribute changes to "true" in the HTML but Click has no effect on the checkbox.
I have tried using the getElementbyClassName method and using Click after that to no avail.
Please help me out on this issue. Do let me know in case you need any other information.
This solution from Zwenn worked perfectly:
First of all, a checkbox has no click event. On topic: Because the whole List of other checkboxes will be marked by marking the one in question, I'am pretty sure the one in question triggers a HTML event like change when you mark it manually. You must check which event it is and trigger it with VBA. You can look for the event with FireFox or Chrome, but not with the IE. Look here how to do that and how to handle with events:
Automate IE via Excel to fill in a dropdown and continue
– Zwenn 14 hours ago

Selecting one value from the dropdown

I am trying to select a value from dropdown list but my script keep on failing. the value that i am selecting is from Excel document with the 'Manager' as the value.
here is my xparth
And Here is my console
i tried different solution but with no luck. the below code is the one i am trying that produced the error.
Select select = new Select(driver.findElement(By.xpath("//*[#id='main']/div/div[2]/form/div[2]/div[7]/div/div[1]/div[1]")));
select.deselectAll();
select.selectByVisibleText(AGR);
Will appreciate your help.
The code should be select.selectByVisisbleText("Manager"). Partial Text is not accepted.Complete text should be entered.
finally i found solution to my problem. all i had to do is to find the xPath and send keys from the excel doc and click enter on the keyboard. this means i can change the name that is on the dropdown on the excel document, rather than hard code it on code.
WebElement webElement = driver.findElement(By.xpath("//*[#id='main']/div/div[2]/form/div[2]/div[7]/div/div[1]/div[1]/input"));//You can use xpath, ID or name whatever you like
driver.findElement(By.xpath("//*[#id='main']/div/div[2]/form/div[2]/div[7]/div/div[1]/div[1]/input")).sendKeys(AGR);
webElement.sendKeys(Keys.ENTER);
hope my solution can help any one experiencing the same issue.

How do I take the title of a website and add it to an Excel spreadsheet using AppleScript + Excel

I'm pretty sure this is an easy task, but I can't seem to find what I'm looking for.
In short, I would like to use a keyboard shortcut take the title of the current page I'm on, and save it to an Excel document, basically creating a log of websites. If possible, I would like to add a link to the title that is saved in Excel.
I know how to add the Applescript as a service or workflow and such, but I can't wrap my mind around how to code this. The farthest I've gotten is grabbing the name of the website, but have no clue how to paste it to Excel, add a link to the title, then go to the next line.
Thank you for any assistance you may have.
Try these two lines of AppleScript
tell first document of application "Safari" to set pageTitle to name
tell first document of application "Safari" to set pageURL to URL

form view in excel for a record

I have a sheet in excel that is basically like a database (yes it has to be in excel unfortunately) and I want to design a simple form to display the records (the different column values in the rows). Usually MS is good with making widgets to do this but I cant seem to figure out how to write it in VBA (easily)
Basically I have a list of Names and ID#'s then some other columns that need to be filled in (address, order # etc) but I'd like the user to do this via a form rather than typing in excel. I created a small form in VBA, but now I cant link the columns to the textboxes in the form.
Anyone know of any code I can plug and play to do this.
Specifically I am using a ComboBox (for the list of names) and then a for loop searching through it to find the selection and updating data. But its a real pain.
plus I cant figure out how to put in a 'Next' button, which is really annoying me. Does anyone know how to change the comboBox value to the next row, if it is linked via RowSource
Have you considered the Form feature? You can find under the commands you can add to your QuickAccess toolbar.
Check this helpful tutorial for additional details.

Resources