Hi All,
I am using vba to navigate internet explorer 8 (IE) to a webpage then find a HTML "textarea" then read and replace the value in this text area with a variable from my macro.
So far I have the following that works (see below) - The problem is that I cannot replace the "textarea" value. I can select the text area and read the value but not write to it.
Sub Add_Users_Test2()
Dim test As String
Dim IE As Object, TB As Object
Set IE = CreateObject("InternetExplorer.Application")
With IE
.Visible = True
.Navigate "URL_HERE"
Do Until .readyState = 4: DoEvents: Loop
Set objCollection = IE.Document.getElementsByTagName("textarea")
i = 0
While i < objCollection.Length
testname = objCollection(i).Name
testvalue = objCollection(i).Value
If objCollection(i).Name = "ctl00$PlaceHolderMain$ctl00$ctl01$userPicker$downlevelTextBox" Then
Set objElement = objCollection(i)
objElement.Click
'objCollection(i).outerHTML = "Test"
Else
End If
i = i + 1
Wend
End With
End Sub
I can get round the above using sendkeys but I am having all sorts of issues with this method - It jumbles and adds letters to my predefined Variable - Sometimes it works, most times it doesn't e.g.
Var1 = "LTest"
the Sendkeys version (or one of them) => "LLLTesst"
Anyone provide any input in how to write a value to the text area??
I have tried so far with no luck - The following dont do anything...
'try 1
objElement.value= "Test"
'try 2
objCollection(i).value= "Test"
'try 3
objElement.innerHTML= "Test"
'try 4
objCollection(i).innerHTML= "Test"
Thanks in advance...
Bookmarks