我已经做了很多测试,并尝试了很多建议,但是似乎什么也没用。我认为这部分是由于流程的Web部分的设置方式所致。在VBA的这一部分中,我尝试通过声明输入名称来命名输入元素,但它不起作用。 Webiste是一个公司网站,其设置方式很怪异,因此我很挣扎。
我需要的代码使用带有2列的excel文档-Col A具有到基于Web的系统中每个人员配置文件的超链接列表,Col B具有针对每个超链接的人员代码。
因此,我需要以下代码: 1.单击“ Excel工作表”列A中的第一个超链接,并在IE中的新页面中打开 2.等待页面加载 3.在“ Excel工作表”列B中,复制列表中的第一个代码 3.在打开的IE页面中,选择标签几次,直到到达正确的字段(因为选择输入字段无效) 4.将复制的代码粘贴到字段中 5. Sendkeys Enter,它将数据保存到字段 6.等待页面加载 7.关闭IE页面 8.循环单击列表中的下一个超链接,然后重复处理直到列表结束
如果有人可以帮助,我将不胜感激!我是VBA新手,所以任何建议,编码都很棒。
非常感谢! 迈克
这是我到目前为止尝试过的(不起作用)
Sub submitFeedback3()
Application.ScreenUpdating = False
Set links = Sheets("Links List")
Set linkList = links.Range("A1", links.Range("A" & Rows.Count).End(xlUp))
Set ID = Sheets("Links List")
Set IDList = ID.Range("B1", ID.Range("B" & Rows.Count).End(xlUp))
Application.DisplayAlerts = False
StartTime = Now
For Each URL In linkList 'open each link
Shell (browserPath & " " & URL.Value)
For Each Cel In IDList
SendKeys "^c" '= copy
Set IE = Nothing
Application.SendKeys "{TAB}", True
Application.SendKeys "{TAB}", True
Application.SendKeys "{TAB}", True
Application.SendKeys "{TAB}", True
Application.SendKeys "{TAB}", True
Application.SendKeys "{TAB}", True
Application.SendKeys "{TAB}", True
Application.SendKeys "{TAB}", True
Application.SendKeys "{TAB}", True
Application.SendKeys "{TAB}", True
Application.SendKeys "{TAB}", True
Application.SendKeys "{TAB}", True
Application.SendKeys "{TAB}", True
Application.SendKeys "{TAB}", True
SendKeys "^v"
SendKeys ("{ENTER}")
Next Cel
Next URL
Application.DisplayAlerts = True
End Sub
更新的代码:
Option Explicit
Const browserPath As String = "C:\Program Files\Internet
Explorer\iExplore.exe"
Dim IE As Object
Dim LatestDate, StartTime
Dim links As Worksheet, linkList As Range, ID As Worksheet, IDList As Range,
URL
As Range, Cel As Range
Sub submitFeedback3()
Application.ScreenUpdating = False
Set links = Sheets("Links List")
Set linkList = links.Range("A1", links.Range("A" & Rows.Count).End(xlUp))
Set ID = Sheets("Links List")
Set IDList = ID.Range("B1", ID.Range("B" & Rows.Count).End(xlUp))
Application.DisplayAlerts = False
StartTime = Now
For Each URL In linkList 'open each link
Shell (browserPath & " " & URL.Value)
While IE.Busy
DoEvents
Wend
For Each Cel In IDList
SendKeys "^c" '= copy
With IE
.getElementById ("employee.dealerPortalUserId")
SendKeys "^v"
SendKeys ("{ENTER}")
End With
Next Cel
Next URL
Application.DisplayAlerts = True
End Sub