A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
We demand answers.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi,
I am using VBA(Excel) webbroswer (InternetExplorer) control to open a webpage with javascript code like ".Selected = true " which doesn't work properly. It works with C# webbrowser control and any browser, like IE, edge, Chrome and Firefox but VBA browser control.
Here is my html page source code (not the real page I am accessing but having the same issue). The problem is caused by "s[i].selected = s[i].value==lang;"
=======================
<html>
<body>
<h1>Test Language</h1>
<SELECT tabIndex=0 id=slang title="Select a Language:" class=selector name=currentLanguage message="FND_SSO_LOGIN_LANG_SELECT" onchange="changeVal()">
<OPTION lang=pt title="Brazilian Portuguese" value=PTB>Português (Brasil)</OPTION>
<OPTION lang=en title="Simple Chinese" value=CN>Chinese</OPTION>
<OPTION lang=en title="American English" value=US>English</OPTION>
</SELECT>
<script>
function changeVal(){
s=document.getElementById('slang');
lang = s.value
for (var i = 0;s && i < s.length;i++) {
s[i].selected = s[i].value==lang;
}
}
</script>
</body>
</html>
============================
The function walks through the whole list of this listbox and set the 'Selected' property to true if the value is equal to the current selected value.
With the VBA webbrowser control, it will set every item in the list to true and finally the last item in the list will be selected. For example, when I change the value from 'PTB' to 'CN', it will trigger the onChange event and finally set the 'EN' as selected as 'EN' is the last item in the list.
My VBA code is very simple and :
==========================
'Public WithEvents objIE As WebBrowser 'Tried this one as well. Didn't work either
Public WithEvents objIE As InternetExplorer
Set objIE = Me.Controls.Add("Shell.Explorer.2") 'Me is a userform to embed the webbrowser control
objIE.Navigate sLoginURL
==========================
The limitation here is:
Did anyone have the same issue as mine?
I think this is an issue of webbrowser control and it's hard or maybe impossible to fix from VBA code. I am also looking for the replacement of webbrowser control. Does anyone know any other solution of webbrowser control replacement?
I have been stuck for a long time. I would appreciate if someone can help.
Thanks,
Lily
A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.
Comments have been turned off. Learn more
We demand answers.