My issue is attempting to interact with a website using VBA.
I have dealt with filling in input boxes by simply saying ie.document.getElementById(strId).value = my_value as well as when those elements exist inside of a form.
But for the life of me I cannot get this to work. I will post as much of the HTML as I can.
HTML:
<input title="Order Number" class="mtn-srch-text text-field req" id="orderNum" type="text" maxLength="10" data-sticky-placeholder="Order Number">
VBA that is attempting to take the orderNum field and fill it in.
objBrowser.document.getElementById("orderNum").value = "1234"
Object Required error each time, so I am thinking its not looking in the right spot as the element surely exists, but I am incorrectly pointing to it. Since I do not see any form tags in the HTML on this page, I did not know how to proceed to drill down to get this input box filled. Any advice would be awesome!
Adding some more of the code, had to remove a few of the URLS and username/pass but as you can see navigating is very simply until we get to the iFrames part of it. Which I now see each iFrame has a differebt SRC which is probably why
.contentDocument.getelementbyId("textbox").value = "test"
wont work. What we are focused on is everything below the dotted line, as you can see its just me toying around stepping through an attempting different things.
Dim strPosUrl As String, strUsername As String, strPassword As String, _
strStoreDomId As String, strStore As String, _
strBtnStoreUpdateDomId As String, strOrder As String, _
strLoadingSpinner As String, strCssAttributeSpinner As String, _
strCssTextSpinner As String
Dim objBrowser As Object 'SHDocVw.InternetExplorer
Dim blnSsoLogin As Boolean
Dim intStoreColNum As Integer, intOrderColNum As Integer, _
intCreditCardColNum As Integer
'Dim doc As MSHTML.HTMLDocument
'these are test vars-----------------
strStore = "Data"
strOrder = "Data"
'----------------------------------
strLoadingSpinner = "spinnerUnique"
strCssAttributeSpinner = "style"
strCssTextSpinner = "display: none;"
strUsername = "example"
strPassword = "EXample"
strStoreDomId = "orderLocInputId"
strBtnStoreUpdateDomId = "orderLocValueUpdate"
strPosUrl = "https://example.jsp"
Set objBrowser = New InternetExplorerMedium
objBrowser.Visible = True
browserNavigate strPosUrl, objBrowser
browserWait objBrowser
blnSsoLogin = ssoLoginCheck(objBrowser)
Select Case blnSsoLogin
Case Is = True
ssoLoginMod strUsername, strPassword, objBrowser
browserWait objBrowser
Case Is = False
End Select
fillTextboxWithId objBrowser, strStoreDomId, strStore
clickButtonWithId objBrowser, strBtnStoreUpdateDomId
browserWait objBrowser
foundOrNot strLoadingSpinner, strCssAttributeSpinner, _
strCssTextSpinner, objBrowser
'-----------------------------------------------------
Dim IFrameText As Object
Set IFrameText = objBrowser.document.getElementById("frmHome")
IFrameText.HTML.getElementById("ordernum").Value = "1223"
Dim x As String
objBrowser.navigate "https://xxxxxxx.xxxxxxx.com" & x
x = objBrowser.LocationURL
x = "just messing with stuff"
Set IFrameText = objBrowser.document.getElementById("frmHome")
Dim elem As Object
For Each elem In IFrameText
If elem.innerText Like "*true*" Then
MsgBox (elem)
End If
Next