IE - Selecting multiple Selections from Select element - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

IE - Selecting multiple Selections from Select element

MacroMan2MacroMan2 Posts: 1Member
Hi everyone,
I have some code below, that is used to select an option from a drop down list and submit a form, which works fine. My work has just changed the drop down box to a multi select box. How can I change the following lines to select multiple items in one go?
[code]For i = 1 To 200
myIE.Document.forms(mySearchForm).elements(mySearchInput).Value = Sheets("Currencies").Cells(i, 3).Value
Next i[/code]
I thought the above code should work, but each time it loops, it selects a new value instead of adding to the current selection.

The full code in current use is this:

[code]Sub AddCur()
Sheets("Auto Currencies").Unprotect
Sheets("Auto Currencies").Cells(13, 13).Value = "0"
Const myPageTitle As String = "Manage Currency Codes"
Const mySearchForm As String = "manageCurrency"
Const mySearchInput As String = "currencyCode"
Const myStatusInput As String = "currencyStatus"
Const myStatus As String = "002"
Const myButton As String = "Add"
Dim i As Integer
Dim AIndex As Double
Dim AddAm As Double

Dim myIE As SHDocVw.InternetExplorer

'check if page is already open
Set myIE = GetOpenIEByTitle(myPageTitle, False)

AddAm = 100 / Application.CountA(Sheets("Currencies").Range("C:C"))

For i = 1 To 200
If (Sheets("Currencies").Cells(i, 3).Value = "") Then
Exit For
End If
With myIE.Document.forms(mySearchForm)
'enter search term in text field
.elements(mySearchInput).Value = Sheets("Currencies").Cells(i, 3).Value
'press button "Go"
.elements(myStatusInput).Value = myStatus
End With
Dim vReadyState 'check if page is fully loaded. 4 = loaded
vReadyState = 0
Application.Wait DateAdd("s", 2, Now)
Do Until vReadyState = 4
vReadyState = myIE.ReadyState
AIndex = AIndex + AddAm
Sheets("Auto Currencies").Cells(13, 13).Value = AIndex
Next i
Sheets("Auto Currencies").Cells(13, 13).Value = ""
Sheets("Auto Currencies").Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
MsgBox ("Add all currencies complete.")
End Sub[/code]
Many thanks for your help

Sign In or Register to comment.