1

I am writing a macro in VBA connected to the following website: https://sphere.ush.inbcu.com/index.html#/ (Probably you won't be able to login there).

There are two elements: On the left there is a dropdown menu - on the right there is a textbox.

If user did not choose anything from dropdown menu - it is not possible to put any input inside the textbox. User needs to select an item from the dropdown menu - then it is possible to put the input in the textbox.

I have written a code that selects an item from the dropdown menu - however when macro does it - the textbox on the right is still 'grey', it is not possible to write any input there. When user manually clicks on the dropdown menu and selects an item - the textbox is not grey and it is possible to provide input there.

I have tried various methods. I have examined both elements and tried to set their attributes such as:

element.setAttribute("disable") = ""
element.setAttribute("autocomplete") = "on"
element.setAttribute("aria-expanded") = "true"

I have noticed that those attributes should have those attributes when textbox is allowed to provide an input inside. When the textbox is 'grey' and it is not possible to provide the input, their attributes are: "disabled", "off", "false". However - nothing has changed, settings those attributes via macro - does not change anything.

HTML Code for dropdown menu: '<select class="form-control input-sm ng-pristine ng-valid ng-empty ng-touched" ng-change="Tile.clearResults()" ng-model="Tile.searchData.searchBy" ng-options="item as item for item in Tile.searchBy"><option value="string:Deal" label="Deal">Deal</option><option value="string:Deal/Order" label="Deal/Order">Deal/Order</option><option disabled="" selected="selected" value="">Search By</option><option value="string:Department System Number" label="Department System Number">Department System Number</option><option value="string:Invoice/Statement #" label="Invoice/Statement #">Invoice/Statement #</option></select>'

'<option value="string:Deal" label="Deal">Deal</option>
<option value="string:Deal/Order" label="Deal/Order">Deal/Order</option>
<option disabled="" selected="selected" value="">Search By</option>

'

HTML Code for the textbox:

'

<option disabled="" selected="selected" value="">Search By</option>
<input disabled="disabled" class="ui-select-search input-xs ng-pristine ng-untouched ng-valid ng-empty" role="combobox" aria-expanded="false" style="width: 482px;" spellcheck="false" aria-label="Select box" ondrop="return false;" type="search" placeholder="Enter Search Criteria..." ng-class="{'spinner': $select.refreshing}" ng-click="$select.activate()" ng-model="$select.search" ng-disabled="$select.disabled" autocapitalize="off" autocorrect="off" autocomplete="off">

'

Could you please advise which attribute should I change in order to make the textbox allow to put the input inside?

Thank you,

8
  • For testing purpose, try to open the code using developer tools and manually try to remove the disabled attribute to check whether it turned in to enable or not. Also try to remove other ng disabled attributes. try to change the classes. It looks like an angular app which makes it hard to automate from VBA. Commented Aug 1, 2019 at 13:45
  • Hey Deepak. I have checked everything you have requested - removed ng disabled attributes, replaced the classes - however none of those have worked. Could you please advise whether this is possible to automate through VBA? You just need to choose the item from dropdown menu and click it with mouse - then the other textbox 'opens'.
    – Bubool
    Commented Aug 1, 2019 at 14:46
  • As you are already doing, you can easily change the drop down value but here it looks like that angular code has some logic to enabled that input. Which is not accessible through VBA. If it is any simple JS function than we can trigger it from VBA but that not the case here. Commented Aug 2, 2019 at 7:35
  • Hey Deepak, thank you for your answer. So it is not possible to activate elements programmed with angular framework via VBA?
    – Bubool
    Commented Aug 2, 2019 at 12:35
  • 1
    Hey Deepak! After such a long time I have finally figured out a solution: ie.Document.parentWindow.execScript "angular.element.getElementsByClassName(">I put the class name here<")[Number of element].scope().<Here I put the name of the attribute ng-model>.='Value' " And it worked! :-)
    – Bubool
    Commented Aug 23, 2019 at 11:44

1 Answer 1

0

ie.Document.parentWindow.execScript "angular.element.getElementsByClassName(">I put the class name here<")[Number of element].scope()..='Value' "

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.