我坚持以下任务:从Excel文件我发送数据(对于某一列到表单中我发送单元格值)到特定的IE对象预定义。发送输入(〜)密钥使用vba到外部IE对象
使用宏将数据发送到textarea字段中的网站(通过ID:id1在网站上标识)。对于添加到网站的textarea字段中的每个单元格值/数据,需要自动完成/附加Enter键/命令,因为这会生成一些空的输入字段,以便自动在网站上完成(代码如下:)
我用自动的方法挣扎发送ENTER键到网站变成textarea的数据插入
后代码更新..
Sub adddata()
Dim objIE As Object
Dim objTR As Object
Dim i, j, counter As Integer
Dim lastRow As Long
counter = 1
Set objIE = GetIeByTitle("https://exampletest.com", True, True)
Dim lastRow2 As Integer
lastRow2 = Workbooks(path1).Worksheets("Test").Range("A" & Rows.Count).End(xlUp).Row
Workbooks(path1).Worksheets("Test").Activate
contor = 1
'First of all the unhidden files have to be take from the target excel file
'Selecting the unhidden lines from the excel file
For j = 1 To lastRow2
If Rows(j).EntireRow.Hidden = False Then
Workbooks(path1).Worksheets("Test").Range("A" & j & ":Z" & j).Select
Selection.Copy
ThisWorkbook.Worksheets("Test2").Range("A" & counter).PasteSpecial
counter = counter + 1
End If
Next j
'look into the new excel file containing just the unhidden lines
'Afterwards a look up through new excel file cells
For i = 2 To counter
objIE.document.getelementbyid("id1").Value = Worksheets("Test2").Range("C" & i).Value ' taking the value from the cell and adding it on the text area field
objIE.document.getelementbyid("id1").SetFocus
Application.SendKeys "~" ' sending the enter key
Application.Wait (7) ' add the delay of 7 seconds
'2nd field
objIE.document.getelementbyid("id2").Value = Worksheets("Test2").Range("D" & i).Value
'3rd field
objIE.document.getelementbyid("id3").Value = Worksheets("Test2").Range("E" & i).Value
Next i
End Sub
这是你的实际代码?它不会编译... –