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

Please help about controlling dropdown menu on HTML by VBA

bistroman

New Member
Hi Everybody.
i am industrial engineer and having some little problem about the code: what's wrong with it?

>>> use code - tags <<<

Code:
Sub ef()

  
Dim IE As InternetExplorer, tmpUrl As String
Set IE = New InternetExplorerMedium
    IE.Visible = True
tmpUrl = "https://daytime.intra/ng/ngLogin.faces" 

IE.Navigate tmpUrl
Do While IE.Busy
   DoEvents
Loop

Do While Not IE.ReadyState = 4: DoEvents: Loop
IE.Document.getElementsByName("form1:textusername")(0).Value = "George"
IE.Document.getElementsByName("form1:password")(0).Value = "123456"
IE.Document.getElementById("form1:btnLogin").Click

' EVERYTHING IS OK until here, it automatically clicks the button at last and new page opens where dropdown menu is out of control of me!
PROBLEM STARTS AFTER THIS:

Do While Not IE.ReadyState = 4: DoEvents: Loop

IE.Document.getElementById("form2:menuSistem").Focus
'IE.Document.getElementById("form2:menuSistem").Value = "Afternoon"

Do While Not IE.ReadyState = 4: DoEvents: Loop
End Sub
------------------------------------------------------------------------------------------

drowndown menu comes default as "Choose " but i want to change it TO AFTERNOON by VBA CODE

drowndown menu can not select the value "Afternoon", Why???

here is the some important parts of HTML CODES:

Code:
}

    function func_logout() {
        inFormOrLink = true;
        document.getElementById('form2').target = '_top';
        document.getElementById('form2:hiddenSistemURL').value = 'LOGOUT';
        document.getElementById('form2:menuSistem').value = '1';
        customWindow('_top','/sso/Logout.faces', 'K');
    }

<TD width="234px" height="25px" bgcolor="#F4F4F4" align="left" valign="bottom"><select id="form2:menuSistem" name="form2:menuSistem" size="1" onchange="func_1('form2:menuSistem')" class="selectOneMenu">    <option value="0">Choose</option>    <option value="62">Morning</option>  <option value="44">Afternoon</option>    <option value="19">Night</option></select></TD>



i will really appreciate and will be gratefull for your help
 
Last edited by a moderator:

vletm

Excel Ninja
bistroman
Where have You tried to change "Choose" to AFTERNOON?
... or have You?
Your pasted code has one line which has word "Afternoon".
Those could be different terms!

Have You tried to take that lines the 1st mark away?
... then that line could use with Your code too ( not only as a comment ).

Have You reread Forum Rules
There are useful advices
How to get the Best Results at Chandoo.org
 

bistroman

New Member
i meant Afternoon of course, not with big letters.

so you mail is not helpful, is it?

i do not know why i am not managing the combobox on intranet, although i 've managed username and password and click button as you can see in the vba code above.
 

vletm

Excel Ninja
bistroman
I gave You three hints ...
a) CAPITAL or not - You comment -- sometimes size matters! sometimes ... not!
b) Take one mark away - You skipped
c) Reread Forum Rules, especially How to get the Best Results at Chandoo.org -- You skipped

You sent ... i do not know... -sentence ( - I can only guess, why You don't know... )
Your code shows that You've .Focused it - that won't be enough, even if operate that manually.
 

vletm

Excel Ninja
bistroman
If You are as You wrote then the challenge!

I try with one line from my previous reply:
b) Take one mark away - as I tried to give a hint for You?
>> after above line
from #5 reply...
Have You tried to take that lines the 1st mark away?
... then that line could use with Your code too ( not only as a comment ).


Or
Have You only copy & paste some code somewhere?
 

vletm

Excel Ninja
bistroman
1) Open Your file, which You have that code
2) Find that part of code Sub ef()
3) Find that line of code which ends with "Afternoon"
4) Move Your cursor in the beginning of that line
5) Press <SHIFT>-button and keep it pressed
6) Press <RIGHT-ARROW>-button once
7) Release <SHIFT>-button
8) Click <DELETE>-button
 

bistroman

New Member
the reason is not because of that. sorry, i delete ' at the begining and problem is going on.

Object variable or With block variable Not set.

it shows these rows with yellow sign:

>>> use code - tags <<<
Code:
IE.Document.getElementById("form2:menuSistem").Focus
IE.Document.getElementById("form2:menuSistem").Value = "Afternoon"
 
Last edited by a moderator:

vletm

Excel Ninja
bistroman
Was above row yellow before? Yes or No?
If Yes ... then ... I just remember to write that?
If No ... then You could have there TYPO.

Try to do step
c) Reread Forum Rules, especially How to get the Best Results at Chandoo.org
 

vletm

Excel Ninja
bistroman
If You skip to explain what is going in there ... someone else could only guess ... guess ... guess!

Fourth time:
Try to do step
c) Reread Forum Rules, especially How to get the Best Results at Chandoo.org
ps. I do not have or use 'Internet Explorer!
 
Top