-
Aug 9th, 2013, 09:41 AM
#1
Thread Starter
New Member
Filling an Onchange Combobox [+HELP]
Hello,
I am filling this form on a Intranet website that has textboxes and comboboxes.
The code is working fine until now.
However, there is a combobox that "depends" on another combobox.
That is, the second combobox is activated after the first one has an option selected. Through researches, I think it's a Combobox Onchange . Not sure, please correct me if I am wrong.
The thing is, I am being able to populate the first combobox, but the second one does not present any options besides "Select". Even after running the Macro, if click manually in the second combobox, it does not show any options but Select in the list.
How can I choose an option from a Onchange Combobox ?
Here's my code so far..
Code:
Sub AcessaPagina()Dim ie As InternetExplorer
Set ie = New InternetExplorer
ie.Navigate "http://epmo.intranet.com//Webforms/TaskCreation.aspx"
Do 'Wait till the edit page is loaded.
Loop Until ie.ReadyState = READYSTATE_COMPLETE And Not ie.Busy
ie.Document.getElementById("Content_TEXT_ALPHA_COLUMN1").Value = "COMPANY"
ie.Document.getElementById("Content_TEXT_ALPHA_COLUMN2").Value = "COMPUTER"
ie.Document.getElementById("Content_TEXT_ALPHA_COLUMN14").Value = "5555"
ie.Document.Forms(0).Item("Content_ddlRegion").Value = "28"
ie.Document.Forms(0).Item("Content_ddlSubRegion").Value = "33"
ie.Document.Forms(0).Item("Content_ddlPriority").Value = "23"
ie.Document.Forms(0).Item("Content_ddlActivity").Value = "13720"
ie.Document.Forms(0).Item("Content_ddlClientCode").Value = "37"
ie.Document.Forms(0).Item("Content_ddlCompanyCode").Value = "62"
ie.Document.Forms(0).Item("Content_DDL_COLUMN1").Value = "5978"
ie.Document.Forms(0).Item("Content_DDL_COLUMN2").Value = "5966"
ie.Visible = True
End Sub
And here is part of the code from the Website..
Code:
Activity :
</td>
<td style="width: 160px;" align="left">
<select name="MasterPage$Content$ddlActivity" onchange="javascript:setTimeout('WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("MasterPage$Content$ddlActivity", "", true, "", "", false, true))', 0)" id="Content_ddlActivity" tabindex="14" title="Classification of submitted request." class="DROPDOWNLIST_CLASS" style="width:150px;">
<option selected="selected" value="0" Title="--Select--">--Select--</option>
<option value="13718" Title="COR">COR</option>
<option value="4339" Title="1">Order 1</option>
<option value="13720" Title="2">Order 2 </option>
<option value="13719" Title="2">Order 3</option>
</select>
<span id="Content_rfvddlActivity" style="color:Red;display:none;">*</span>
</td>
<td style="width: 160px;" align="right">
-
Aug 9th, 2013, 04:34 PM
#2
Re: Filling an Onchange Combobox [+HELP]
search in this or the vb6 forums for fireevent, i have posted examples previously
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Aug 12th, 2013, 07:04 AM
#3
Thread Starter
New Member
Re: Filling an Onchange Combobox [+HELP]
Originally Posted by westconn1
search in this or the vb6 forums for fireevent, i have posted examples previously
Thank you Westconn1 !
I used....
Code:
ie.Document.Forms(0).Item("Content_ddlActivity").Focus
ie.Document.Forms(0).Item("Content_ddlActivity").Value = "13720"
ie.Document.Forms(0).Item("Content_ddlActivity").FireEvent ("onchange")
... and now the Onchange field shows all options for me to choose.
However, in the webpage's source code its not possible to find any values besides the "Select" one as per below:
Code:
Sub-Activity :
</td>
<td style="width: 160px;" align="left">
<select name="MasterPage$Content$ddlSubActivity" id="Content_ddlSubActivity" tabindex="15" title="Classification type of submitted request." class="DROPDOWNLIST_CLASS" style="width:150px;">
<option value="0" Title="--Select--">--Select--</option>
</select>
<span id="Content_rfvSubActivity" style="color:Red;display:none;">*</span>
</td>
</tr>
<tr>
<td align="right" style="width: 200px;">
Is this normal?? In the Source, all the others fields have lots of values except this one.
Thanks for the help!
-
Aug 12th, 2013, 07:31 AM
#4
Thread Starter
New Member
Re: Filling an Onchange Combobox [+HELP]
Nevermind, I found the values performing a search in the developer tools!
So, now I have ...
Code:
ie.Document.Forms(0).Item("Content_ddlActivity").Focus
ie.Document.Forms(0).Item("Content_ddlActivity").Value = "13720"
ie.Document.Forms(0).Item("Content_ddlActivity").FireEvent ("onchange")
ie.Document.Forms(0).Item("Content_ddlSubActivity").Value = "13735"
... BUT the field is not being filled.
Is there something I have to put after the FireEvent before putting the ie.Document.Forms(0).Item("Content_ddlSubActivity").Value = "13735"
??
Thanks!!
-
Aug 12th, 2013, 08:16 AM
#5
Re: Filling an Onchange Combobox [+HELP]
values for a dropdown list have to be in the list for the dropdown list, this can be written /rewritten at runtime, but only listed values can be inserted, they do not need to be in the page source
Is there something I have to put after the FireEvent before putting the
you have to wait for the page to load the list, i am not sure if the ie will be busy or if readystate will change during the loading of the dropdown, you may have to test, else just put some delay loop for however long seems appropriate
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Aug 12th, 2013, 09:57 AM
#6
Thread Starter
New Member
Re: Filling an Onchange Combobox [+HELP]
Originally Posted by westconn1
values for a dropdown list have to be in the list for the dropdown list, this can be written /rewritten at runtime, but only listed values can be inserted, they do not need to be in the page source
you have to wait for the page to load the list, i am not sure if the ie will be busy or if readystate will change during the loading of the dropdown, you may have to test, else just put some delay loop for however long seems appropriate
Thanks again, Westconn1..
I got it with
Code:
While ie.Busy
DoEvents
Wend
Application.Wait Now() + TimeValue("00:00:03")
The thing is, I want the macro to run in the current Internet Explorer window instead of opening a new window everytime.
Is it possible?
Last edited by The World Is Yours; Aug 12th, 2013 at 01:35 PM.
-
Aug 12th, 2013, 04:31 PM
#7
Re: Filling an Onchange Combobox [+HELP]
yes, internet explorer windows are members of the shell windows collection
Code:
set sh = createobject("shell.application")
msgbox sh.windows.count & " open shell windows" ' not required
for each w in sh.windows
' test here for internet explorer, then run code
next
if you put a reference to shell you can use early binding, as there can be many open shell windows, you will have to find some specific criteria to identify the correct window
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|