Hello All,
Can somebody help me with a vba code to copy and paste a range of Excel data into search box in Internet Explorer and submit?
The element ID of the textbox is "Textarea1"
I have attached the Excel image and textbox image
Thanks
N
Hello All,
Can somebody help me with a vba code to copy and paste a range of Excel data into search box in Internet Explorer and submit?
The element ID of the textbox is "Textarea1"
I have attached the Excel image and textbox image
Thanks
N
Last edited by Niclal; 08-28-2013 at 07:11 AM.
Hi,
I have used following vba script, but the thing is, I am not getting all items as in the attached textbox.PNG, but only one item remains. Obviously, the second item in the list is replacing the first, the third is replacing the second, etc. I just need the whole list pasted.
Sub Fill_Form()
Dim IE As Object
Dim mytextfield As Object
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.navigate "http://www.example.com/"
Do Until IE.readystate = 4
DoEvents
Loop
Set mytextfield = IE.document.all.Item("Textarea1")
mytextfield.Value = Sheets(1).Range("A1").Value
End Sub
Can you post the actual URL?
If posting code please use code tags, see here.
Unfortunately, I can't, that's why I am using http://www.example.com/
I have also managed to paste the items as a comma-separated string, but I need a paragraph-separated string, one item per line.
Maybe , you have an idea how to convert the comma-separated string and paste the results, which is also a solution.
As I already mentioned, the URL is an intranet.
Thanks
I have changed the script a bit. I am almost there. I just need to convert the comma in a linebreak, and I still need your help:
Sub Fill_Form()
Dim IE As Object
Dim mytextfield As Object
Dim arrString As Variant
Dim i As Long
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.navigate "http://www.example.com/"
Do Until IE.readystate = 4
DoEvents
Loop
arrString = Split(Range("A1"), ",")
For i = 0 To UBound(arrString)
Set mytextfield = IE.document.all.Item("Textarea1")
mytextfield.Value = arrString(i)
Next i
End Sub
Sorry I can't really give proper help without seeing the actual page.
From what I see in your code all you are doing is putting the value(s) from A1 into the textbox one at a time, not all together.
Also, the code doesn't seem to tally with the image.
In the image you appear to have multiple values in multiple cells but the code only refers to one cell, A1, which according to the image only has one value in it.
PS When posting code please use code tags - kind of a forum rule.
Hi Norie,
The code applies to the image Capture_NEW.PNG. Sorry for that.
Basically, you are right. I just want to put the values all together at once into the textbox not comma-separated, but separated with a line-break
Sorry for not sticking to the rules.
The result of the attached code looks like Result.PNG. As I said, comma should be replace by newline.Sub Fill_Form()
Dim IE As Object
Dim arr As Variant
Const DELIMITER = vbCr
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.navigate "http://www.example.com/"
Do Until IE.readystate = 4
DoEvents
Loop
With ActiveSheet
arr = WorksheetFunction.Transpose(.Range(.[A1], .Cells(Rows.Count, "A").End(xlUp)))
If Not IsArray(arr) Then arr = Array(arr)
IE.document.getElementById("Textarea1").Value = Join(arr, DELIMITER)
End With
End Sub
arr is only going to have 1 value ,"'EP1024135A1', ..., 'EP1061075A2'".
Try replacing the commas in A1 with vbCrLf using the Replace function.
![]()
Please Login or Register to view this content.
Last edited by Norie; 08-29-2013 at 05:16 AM.
Hi Norie,
Thank you, thank you, thank you
N
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks