How to click on the save button when pop-up appears? - html

I am using Internet Explorer to click on a file.
I get to a point where an Internet Explorer pop-up appears saying "Do you want to open or save the file?":
I want to write a VBA code that clicks on the save button.
I realized it is not possible to right click and "inspect element" in order to show the HTML page because the pop-up is not part of the internet explorer webpage.
So I tried the sendKeys method even though it is not reliable. I tried different options such as :
Application.SendKeys "%S"
Application.SendKeys "%s"
Application.SendKeys "%{S}"
Application.SendKeys "%{s}"
SendKeys ("%S")
SendKeys ("%s")
SendKeys ("%{S}")
SendKeys ("%{s}")
Application.SendKeys "%{S}"
When I run the code, none of them save the file.
Where is my error?
Are there other propositions to click on that "Save" button?
Maybe the object to which I am applying SendKeys should not be "Application"?

If you wish to use the UIAutomationCore.dll and reference it, you can do something like:
Public Function AutoSave() As Boolean
On Error Goto handler
Dim sysAuto As New UIAutomationClient.CUIAutomation
Dim ieWindow As UIAutomationClient.IUIAutomationElement
Dim cond As IUIAutomationCondition
Set cond = sysAuto.CreateAndCondition(sysAuto.CreatePropertyCondition(UIA_NamePropertyId, "Notification"), _
sysAuto.CreatePropertyCondition(UIA_PropertyIds.UIA_ControlTypePropertyId, UIA_ToolBarControlTypeId))
Set ieWindow = sysAuto.GetRootElement.FindFirst(TreeScope_Descendants, cond)
Dim tField As UIAutomationClient.IUIAutomationElement
Dim tFieldCond As IUIAutomationCondition
Set tFieldCond = sysAuto.CreatePropertyCondition(UIA_ControlTypePropertyId, UIA_ControlTypeIds.UIA_SplitButtonControlTypeId)
Set tField = ieWindow.FindFirst(TreeScope_Descendants, tFieldCond)
Dim invPattern As UIAutomationClient.IUIAutomationInvokePattern
Set invPattern = tField.GetCurrentPattern(UIA_InvokePatternId)
invPattern.Invoke
AutoSave = True
Exit Function
handler:
End Function
And call that routine after clicking on the item - perhaps give it a Hard Wait to allow the Notification bar to show.
EDIT
To invoke the Close Button:
Set cond = sysAuto.CreateAndCondition(sysAuto.CreatePropertyCondition(UIA_NamePropertyId, "Close"), _
sysAuto.CreatePropertyCondition(UIA_ControlTypePropertyId, UIA_ControlTypeIds.UIA_ButtonControlTypeId))
Dim closeButton As IUIAutomationElement
Set closeButton = WaitForElement(ieWindow, cond, 10)
If closeButton Is Nothing Then Exit Sub
Dim clickButtonPattern As IUIAutomationInvokePattern
Set clickButtonPattern = closeButton.GetCurrentPattern(UIA_InvokePatternId)
clickButtonPattern.Invoke
........
Helper function:
Function WaitForElement(rootElement As IUIAutomationElement, condition As IUIAutomationCondition, timeout As Long) As IUIAutomationElement
Dim startTime As Date
startTime = Now
Dim element As IUIAutomationElement
Set element = rootElement.FindFirst(TreeScope_Descendants, condition)
While element Is Nothing And 100000 * (Now - startTime) < timeout
Application.Wait Now + TimeValue("00:00:01")
Set element = rootElement.FindFirst(TreeScope_Descendants, condition)
Wend
Set WaitForElement = element
End Function
You would typically wait until the 'Notification bar Text' element text had changed to have "download has completed" at the end.
This can be done with a couple of helper functions:
Function WaitForTextValue(textElement As IUIAutomationElement, text As String, timeout As Long, Optional exactMatch As Boolean = False) As Boolean
Dim startTime As Date
startTime = Now
Dim result As String
result = ReadValue(textElement)
Dim isMatch As Boolean
If exactMatch Then
isMatch = result = text
Else
isMatch = InStr(1, result, text, vbTextCompare) > 0
End If
'keep reading the element until we have a match, or the timeout has expired
While Not isMatch And 100000 * (Now - startTime) < timeout
Application.Wait Now + TimeValue("00:00:01")
result = ReadValue(textElement)
If exactMatch Then
isMatch = result = text
Else
isMatch = InStr(1, result, text, vbTextCompare) > 0
End If
Wend
WaitForTextValue = isMatch
End Function
Function ReadValue(element As IUIAutomationElement) As String
Dim valPattern As IUIAutomationValuePattern
Set valPattern = element.GetCurrentPattern(UIA_ValuePatternId)
If Not valPattern Is Nothing Then
ReadValue = element.GetCurrentPropertyValue(UIA_ValueValuePropertyId)
Else
' raise error here if element's value cannot be read - err.Raise
End If
End Function
And you would call this check after clicking the 'Save' button like so:
Set cond = sysAuto.CreateAndCondition(sysAuto.CreatePropertyCondition(UIA_NamePropertyId, "Notification bar Text"), _
sysAuto.CreatePropertyCondition(UIA_ControlTypePropertyId, UIA_ControlTypeIds.UIA_TextControlTypeId))
Dim barText As IUIAutomationElement
Set barText = WaitForElement(ieWindow, cond, 10)
If barText Is Nothing Then Exit Sub
If Not WaitForTextValue(barText, "download has completed", 30, False) Then Exit Sub
'if we get to here, then text has changed, and we can go ahead and click close button

Reproduce your problem on my side, it seems that before clicking the Save button, we need time to display the popup file download prompt. So, please try to use the Application.Wait method to wait the prompt display.
Code like this:
Sub Test()
Dim ie As Object
Dim Rank As Object
Set ie = CreateObject("InternetExplorer.application")
ie.Visible = True
ie.Navigate ("http://localhost:54382/HtmlPage47.html")
Do
If ie.ReadyState = 4 Then
Exit Do
Else
End If
Loop
Set doc = ie.document
doc.getElementsByTagName("tr")(1).getElementsByTagName("td")(5).getElementsByTagName("a")(0).Click
Application.Wait (Now + TimeValue("0:00:02"))
Application.SendKeys "%{S}"
End Sub
The screenshot as below:

Related

How to change an html class name using vba?

so I'm having a particular problem. Basically, what I'm trying to do is copy data from my excel and paste it into an internet explorer textbox. I've got as far as pasting it in and pressing the submit button on my webpage. However, my problem is that when using VBA, the submit button remains greyed out and cannot be pressed. The only times where it will not be greyed out is when I manually enter in the data into the textbox or manually paste it into the textbox without using VBA. the HTML code appears as such when the button is greyed out :
<div class="form-group has-error">
and when it is not greyed out :
<div class="form-group">
I was wondering if there's any way to change the class name to the second option through VBA, so that the button becomes clickable? I've tried dabbling with Set attribute, but im not sure if i'm doing it right because I keep getting error messages.
Any ideas?
Here's my full code for context:
Sub ExplorerTest3()
'Requirement:
' In Tools / Reference : Enable Microsoft Internet controls
' In Tools / Reference : Enable Microsoft HTML Object library
Const myPageURL As String = "https://intelcom.horasphere.com/app/#/report-module"
Const mySearchForm As String = "searchform"
Const mySearchInput As String = "searchInput"
Const mySearchTerm As String = "Document Object Model"
Const myButton As String = "Go"
Dim myIE As SHDocVw.InternetExplorer
Dim Doc As HTMLDocument
Dim ID As HTMLElementCollection
Dim BtSearch As HTMLButtonElement
Dim str As String
Dim arr() As Variant
Dim tableRow As Integer
Dim tableCol As Integer
ActiveWorkbook.Activate
Sheets(5).Select
'define sheetname here, if not sheet1
With ThisWorkbook.Sheets(5)
' the below brings back a number which can be used as lastcell. see below
LastRow = Range("A" & Rows.count).End(xlUp).Row
'here is the range
My_Range_Is = .Range("A1:A" & LastRow)
'iterate through range (start at 1 i.e.) end at last filled cell in column A (lastRow)
For i = 1 To LastRow
'do something here
Next i
End With
Set myIE = CHECK_IE_ALREADY_OPEN("")
arr = My_Range_Is
For tableRow = LBound(arr) To UBound(arr)
For tableCol = LBound(arr, 2) To UBound(arr, 2)
str = str & arr(tableRow, tableCol) & vbTab
Next tableCol
str = str & vbNewLine
Next tableRow
With myIE
.Navigate myPageURL
Do While (.ReadyState <> 4) Or (.Busy = True)
DoEvents
Loop
.Visible = True
Set Doc = myIE.Document
.Document.getElementsByClassName("report-module-query-category-item-button btn btn-default")(5).Click
.Document.getElementsByClassName("report-link-button btn btn-default")(3).Click
'Top 2 lines are to click on operation button and task states pivot button
.Document.getElementsByClassName("report-module-query-execution-freeform-area")(0).Value = str
Do While (.ReadyState <> 4) Or (.Busy = True)
DoEvents
Loop
.Document.getElementsByClassName("pull-right report-module-query-list-execute-button btn btn-sm btn-default")(0).Click
End With
End Sub
'.Document.getElementById(mySearchInput).Value = mySearchTerm
'.Document.getElementsByClassName("report-module-query-category-item-button btn btn-default")(5).Click
Function CHECK_IE_ALREADY_OPEN(ByVal URL As String) As Object
Dim objShell As Object
Dim objWindow As Object
Dim objItem As Object
Set CHECK_IE_ALREADY_OPEN = Nothing
Set objShell = CreateObject("Shell.Application")
On Error Resume Next ' sometimes more web pages are counted than are open
Set objWindow = objShell.Windows()
For Each objItem In objWindow
If LCase(objItem.FullName) Like "*iexplore*" Then
If objItem.LocationURL Like URL & "*" Then
Set CHECK_IE_ALREADY_OPEN = objItem
Exit For
End If
End If
Next objItem
On Error GoTo 0
End Function

Need Excel VBA to navigate website and download specific files

Trying to understand how to interact with a website in a specific way. This is part of a larger code I'm working on that will loop through a list of ContractorIDs. What I need to do from here is the following:
Navigate to this website: https://ufr.osd.state.ma.us/WebAccess/SearchDetails.asp?ContractorID=042786217&FilingYear=2018&nOrgPage=7&Year=2018
Find the link that says "UFR Filing with Audited Financials" and click on it. (if it's not there, end the sub)
On the ensuing page, find the link that is identified under "Document Category" as "UFR Excel Template" and click on it. (in this case, the link says "15-UFR18.xls", however since there's no consistent link naming scheme, the correct link will always have to be identified by the label under "Document Category" as mentioned. If the link doesn't exist, exit sub.)
On the ensuing page, click the "Download" link at the top and save the file under the following file path (which would be created at this time): C:\Documents\042786217\2018.
Edit: Code below gets me to the point where the download button is clicked, then I get the Open/Save/Cancel dialog box. Nearly there, just need to figure out how to save the file into a specific path.
Option Explicit
Sub UFRScraper()
If MsgBox("UFR Scraper will run now. Do you wish to continue?", vbYesNo) = vbNo Then Exit Sub
Dim IE As Object
Dim objElement As Object
Dim objCollection As Object
Dim ele As Object
Dim tbl_Providers As ListObject: Set tbl_Providers = ThisWorkbook.Worksheets("tbl_ProviderList").ListObjects("tbl_Providers")
Dim FEIN As String: FEIN = ""
Dim FEINList As Range: Set FEINList = tbl_Providers.ListColumns("FEIN").DataBodyRange
Dim ProviderName As String: ProviderName = ""
Dim ProviderNames As Range: Set ProviderNames = tbl_Providers.ListColumns("Provider Name").DataBodyRange
Dim FiscalYear As String: FiscalYear = ""
Dim urlUFRDetails As String: urlUFRDetails = ""
Dim i As Integer
' Create InternetExplorer Object
Set IE = CreateObject("InternetExplorer.Application")
' Show (True)/Hide (False) IE
IE.Visible = True
i = 1
For i = 1 To 3 'Limited to 3 during testing. Change when ready.
FEIN = FEINList(i, 1)
ProviderName = ProviderNames(i, 1)
urlUFRDetails = "https://ufr.osd.state.ma.us/WebAccess/SearchDetails.asp?ContractorID=" & FEIN & "&FilingYear=2018&nOrgPage=1&Year=2018"
IE.Navigate urlUFRDetails
' Wait while IE loading...
'IE ReadyState = 4 signifies the webpage has loaded (the first loop is set to avoid inadvertently skipping over the second loop)
Do While IE.ReadyState = 4: DoEvents: Loop 'Do While
Do Until IE.ReadyState = 4: DoEvents: Loop 'Do Until
'Step 2 is done here
Dim filingFound As Boolean: filingFound = False
For Each ele In IE.Document.getElementsByTagName("a")
If ele.innerText = "UFR Filing with Audited Financials" Then
filingFound = True
IE.Navigate ele.href
Do While IE.ReadyState = 4: DoEvents: Loop 'Do While
Do Until IE.ReadyState = 4: DoEvents: Loop 'Do Until
Exit For
End If
Next ele
If filingFound = False Then
GoTo Skip
End If
'Step 3
Dim j As Integer: j = 0
Dim UFRFileFound As Boolean: UFRFileFound = False
For Each ele In IE.Document.getElementsByTagName("li")
j = j + 1
If ele.innerText = "UFR Excel Template" Then
UFRFileFound = True
IE.Navigate "https://ufr.osd.state.ma.us/WebAccess/documentviewact.asp?counter=" & j - 4
Do While IE.ReadyState = 4: DoEvents: Loop 'Do While
Do Until IE.ReadyState = 4: DoEvents: Loop 'Do Until
Exit For
End If
Next ele
If UFRFileFound = False Then
GoTo Skip
End If
'Step 4
IE.Document.getElementById("LinkButton2").Click
'**Built in wait time to avoid accidentally overloading server with repeated quick requests during development and testing**
Skip:
Application.Wait (Now + TimeValue("0:00:03"))
MsgBox "Loop " & i & " complete."
Next i
'Unload IE
IE.Quit
Set IE = Nothing
Set objElement = Nothing
Set objCollection = Nothing
MsgBox "Process complete!"
End Sub
I have tried step 3 with some what lengthy way. but could not provide complete download code as (after one successful manual attempt) at present even manual download attempt causing massage "The File Could Not Be Retrieved" (maybe server side constrain)
Code only take you down to the cell containing href of the xlx file
Dim doc As HTMLDocument
Dim Tbl As HTMLTable, Cel As HTMLTableCell, Rw As HTMLTableRow, Col As HTMLTableCol
Set doc = IE.document
For Each ele In IE.document.getElementsByClassName("boxedContent")
For Each Tbl In ele.getElementsByTagName("table")
For Each Rw In Tbl.Rows
For Each Cel In Rw.Cells
'Debug.Print Cel.innerText
If InStr(1, Cel.innerText, "UFR Excel Template") > 0 Then
Debug.Print Rw.Cells(2).innerText & " - " & Rw.Cells(2).innerHTML
End If
Next
Next Rw
Next Tbl
Next
Once the href is available PtrSafe Function or WinHTTPrequest or other methods could be used to download the file. Welcome and eager to learn some more efficient answers in this case from experts like #QHarr and others.

HTML Form Will Not Submit, Likely Form Validation Issues

The following code works just fine when it comes to completing the form located on the webpage. The issue arises when it comes time to submit the form.
This appears to be some an issue with validation, as when the form is completed systematically, the submit button is disabled. However, when I go back over the text boxes and manually type in the exact same information, the submit button then becomes available. I believe the form thinks it is incomplete, thus disabling the submit button. I even systematically reenabled this button using SubmitBtn.disabled = False (which allows it to be manually or systematically clicked), and it still will not submit.
I have never encountered this type of form validation when filling in webpages.
I am currently on Internet Explorer 11
The following code is complete and can be tested without needing modification. This is a website that is made available to the public
Option Explicit
#If VBA7 Then
Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As LongPtr)
#Else
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
#End If
Sub SCRA_Scrub()
' #################################################
' #### LATE BINDING IS REQUIRED ON ALL OBJECTS ####
' #################################################
Dim IE As Object
Dim sSSN As String, sLastName As String, sFirstName As String
sSSN = "123456789"
sLastName = "DOE"
sFirstName = "JOHN"
Set IE = GetIE("scra.dmdc.osd.mil") 'Already Open
If IE Is Nothing Then
Set IE = CreateObject("InternetExplorer.Application") 'Not open
With IE
.Visible = True
.Navigate ("https://scra.dmdc.osd.mil/scra/#/single-record")
End With
Else 'Reset form
Dim ClearBtn As Object
Set ClearBtn = IE.document.getElementsByClassName("btn btn-primary")(0)
End If
Sleep 400
Dim oSSN As Object, oSSN2 As Object, oLastName As Object, oFirstName As Object, SubmitBtn As Object
Dim oCaptcha As Object
Do While IE.Busy Or IE.ReadyState <> 4
DoEvents
Loop
'For some reason, page shows loaded when it's not. Will loop until obj
'becomes available
On Error Resume Next
Do Until Not oSSN Is Nothing And Not oCaptcha Is Nothing
Set oSSN = IE.document.getElementByID("ssnInput")
Set oCaptcha = IE.document.getElementByID("recaptcha_response_field")
DoEvents
Loop
On Error GoTo 0
Set oSSN2 = IE.document.getElementByID("ssnConfirmationInput")
Set oLastName = IE.document.getElementByID("lastNameInput")
Set oFirstName = IE.document.getElementByID("firstNameInput")
oSSN.InnerText = sSSN
oSSN2.InnerText = sSSN
oLastName.InnerText = sLastName
oFirstName.InnerText = sFirstName
IE.document.ParentWindow.Scroll 0&, 710&
oCaptcha.InnerText = InputBox("Security answer (Captcha)")
'IE.Document.Forms(0).submit
Set SubmitBtn = IE.document.getElementsByClassName("btn btn-primary")(1)
SubmitBtn.disabled = False '< The button was disabled, but still doesn't submit
SubmitBtn.Click
End Sub
Function GetIE(sLocation As String) As Object
Dim objShell As Object, objShellWindows As Object, o As Object
Dim sURL As String
Dim RetVal As Object
Set RetVal = Nothing
Set objShell = CreateObject("shell.application")
Set objShellWindows = objShell.Windows
For Each o In objShellWindows
sURL = ""
On Error Resume Next
sURL = o.document.Location
On Error GoTo 0
If sURL Like "*" & sLocation & "*" Then
Set RetVal = o
Exit For
End If
Next o
Set GetIE = RetVal
End Function
Thanks to some assistance, it appears that on this particular form prior to setting the text for each input object that I am required to use object.setActive.
So the code would end as follows:
oSSN.setActive
oSSN.InnerText = sSSN
oSSN2.setActive
oSSN2.InnerText = sSSN
oLastName.setActive
oLastName.InnerText = sLastName
oFirstName.setActive
oFirstName.InnerText = sFirstName
IE.document.ParentWindow.Scroll 0&, 710&
oCaptcha.setActive
oCaptcha.InnerText = InputBox("Security answer (Captcha)")

Editing HTML Code using Excel VBA

I am in need of editing html code using VBA. I actually got this working as far as editing values of text boxes. My problem is that when I simulate clicking the "submit" button there are new tables that come up. The web address stays the same but now there is new html code generated for the tables. I am trying to read data from these tables but it seems as if they don't exist when I try and query them. So I am guessing that I need to update or refresh the IE html code after I press the "submit" button. I can not seem to figure out how to do this. Any help is greatly appreciated. Here is my code so far:
Sub ImportStackOverflowData()
Dim SearchFor As IHTMLElement
Dim RowNumber As Long
RowNumber = 4
'to refer to the running copy of Internet Explorer
Dim ie As InternetExplorer
'to refer to the HTML document returned
Dim html As HTMLDocument
'open Internet Explorer in memory, and go to website
Set ie = New InternetExplorer
ie.Visible = True
ie.Navigate "http://google.com"
'Wait until IE is done loading page
Do While ie.ReadyState <> READYSTATE_COMPLETE
Application.StatusBar = "Trying to go to TRSDataBase ..."
DoEvents
Loop
Set html = ie.Document
Application.StatusBar = ""
'clear old data out and put titles in
Cells.Clear
Set SearchFor = html.getElementById("ddl_process")
'if this is the tag containing the question details, process it
If SearchFor.ID = "ddl_process" Then
'Replace the value of dl-process with copperhead name
Call SearchFor.setAttribute("value", "CPHB_FAT")
Cells(RowNumber, 1).Value = "Successfully replaced ddl_process to : " &
SearchFor.getAttribute("value")
'go on to next row of worksheet
RowNumber = RowNumber + 1
End If
Set SearchFor = html.getElementById("txt_startdate")
If SearchFor.ID = "txt_startdate" Then
'Replace the value of dl-process with copperhead name
Call SearchFor.setAttribute("value", "07-07-17")
Cells(RowNumber, 1).Value = "Successfully replaced startdate to : " &
SearchFor.getAttribute("value")
'go on to next row of worksheet
RowNumber = RowNumber + 1
End If
Set SearchFor = html.getElementById("txt_enddate")
If SearchFor.ID = "txt_enddate" Then
'Replace the value of dl-process with copperhead name
Call SearchFor.setAttribute("value", "07-14-17")
Cells(RowNumber, 1).Value = "Successfully replaced enddate to : " &
SearchFor.getAttribute("value")
'go on to next row of worksheet
RowNumber = RowNumber + 1
End If
'find view button and click it
Set SearchFor = html.getElementById("btn_header")
If SearchFor.ID = "btn_header" Then
SearchFor.Click
Cells(RowNumber, 1).Value = "The View Button has been clicked."
'go on to next row of worksheet
RowNumber = RowNumber + 1
End If
'Now get data from table after it loads
Application.Wait (Now + TimeValue("0:00:20"))
Set html = ie.Document <----------This is where i am trying to update or refresh my code after it loads with the new tables
Debug.Print ie.Document.body.innerHTML
Range("L5").Value = ie.Document.getElementsByTag("table")
(1).Rows(1).Cells(2).innerText
Try getting a new pointer to the window. Sometimes that does the trick.
Public Function FindWindow(SearchBy As String, SearchCriteria As String) As Object
Dim Window As Object
For Each Window In CreateObject("Shell.Application").Windows
If SearchBy = "URL" And Window.LocationURL Like "*" & SearchCriteria & "*" Then
Set FindWindow = Window
Exit Function
ElseIf SearchBy = "Name" And Window.LocationName Like "*" & SearchCriteria & "*" Then
Set FindWindow = Window
Exit Function
End If
Next
Set FindWindow = Nothing
End Function
Sub getNewPointer()
Dim ie As InternetExplorer
ie.Navigate "www.google.com"
'Wait for the page to load and do actions etc
'Your code here
'
'
'Clear the IE reference
Set ie = Nothing
'get a new pointer to the window of interest
'Keep in mind it finds the first matching Window based on your criteria!
Set ie = FindWindow("URL", "www.google.ca")
'Try getting the property you want
Debug.Print
End Sub

Select option from Internet Explorer dropdown list

I am working on opening a webpage and filling out some fields. I managed to fill textboxes, but I am having trouble selecting options from drop down lists checking/selecting radio buttons.
This is the HTML code referring to the dropdown list:
HTML code for drop down list
This one is the code for one of the radio buttons:
HTML code for radio button
This is my code so far:
Sub w()
'
' w Macro
'
' Keyboard Shortcut: Ctrl+w
'
'pick ups cell b2 value
Dim cellvalue As String
cellvalue = ActiveSheet.Cells(1, 2)
Dim HTMLDoc As HTMLDocument
Dim oBrowser As InternetExplorer
''Sub Login_2_Website()
Dim oHTML_Element As IHTMLElement
Dim sURL As String
On Error GoTo Err_Clear
sURL = cellvalue '
Set oBrowser = New InternetExplorer
oBrowser.Silent = True
oBrowser.timeout = 60
oBrowser.navigate sURL
oBrowser.Visible = True
Do
' Wait till the Browser is loaded
Loop Until oBrowser.readyState = READYSTATE_COMPLETE
Set HTMLDoc = oBrowser.document
'fill email response address
HTMLDoc.all.emailAddresses.Value = ActiveSheet.Cells(5, 3)
'fill shipment reference number
HTMLDoc.all.filingRefNumber.Value = ActiveSheet.Cells(5, 7)
'fill dropbox option
'NOT WORKING
If Not VBA.IsNull(ie.document.getElementById("select2-drop-mask")) Then
Dim htmlSelect
Set htmlSelect = ie.document.getElementById("select2-drop-mask")
htmlSelect.Value = 4 - POSTDEPARTURE
Else
MsgBox "Element 'select2-drop-mask' was not found", vbExclamation
End If
'SELECT RADIO BUTTON
' NOT WORKING
ie.document.getElementsByName("shipmentInfo.routedExpTransactionInd.stringFiEld").Item(1).Checked = True
For Each oHTML_Element In HTMLDoc.getElementsByTagName("Login")
If oHTML_Element.Type = "Login" Then oHTML_Element.Click: Exit For
Next
' oBrowser.Refresh ' Refresh If Needed
Err_Clear:
If Err <> 0 Then
'Debug.Assert Err = 0
Err.Clear
Resume Next
End If
End Sub
With respect to your list/dropdown, I think there are two potential solutions.
Change to
htmlSelect.Value = "4 - POSTDEPARTURE"
Refer to the index value. I.e. if it's the first item in the dropdown, it's item(0).
htmlSelect.item(0).selected="True"
For your radio button, wrap 'true' in quotes. Also you'd need to loop through all elements with that particular name (getElementbyID only returns 1 item, but getElementsByName can refer to multiple elements).
e.g.
dim objects
dim obj
set objects=document.getElementsByName("shipmentInfo.routedExpTransactionInd.stringFiEld")
for each obj in objects
obj.item(0).checked=True
next
or try:
Set ieRadio = IE.Document.all
ieRadio.Item("shipmentInfo.routedExpTransactionInd.stringFiEld")(1).Checked = True