Excel VBA脚本使用IE预填网上表格? [英] Excel VBA script to prefill online form using IE?
问题描述
该表单位于一个安全的服务器上,但我已经得到了窗口拉起并选择了窗体。我无法找到一种方法来定位输入字段,因为它们没有ID。以下是我的代码,感谢您的帮助。
Sub Redirect()
Dim IE As Object
Dim doc As Object
Dim form As Object
Dim OldURL As Object
Dim NewURL As Object
设置IE = CreateObject(InternetExplorer.Application)
与IE
.Visible = True
.Navigatehttps:// ....
Do Until .ReadyState = 4:DoEvents:Loop
设置doc = IE.Document
设置form = doc.forms(digiSHOP)
设置OldURL = doc.getElementById(OldUrl)'元素没有ID
OldURL.Value = Range(A2)
设置NewURL = doc.getElementById(NewUrl)
NewURL.Value = Range(B2)
form.submit
Do Until .ReadyState = 4:DoEvents:Loop
Do While .Busy:DoEvents:Loop
End with
End Sub
此外,我不知道如何定位整个列并循环,因此值设置为单元格A2。这更是测试脚本。
Sub Redirect()
Dim IE As Object
Dim doc As Object
设置IE = CreateObject(InternetExplorer.Application)
使用IE
.Visible = True
.Navigatehttps: // ....
Do Until .ReadyState = 4:DoEvents:Loop
With .Document.forms(digiSHOP)
.elements( OldUrl)Value = Range(A2)
.elements(NewUrl)。Value = Range(B2)
.submit
End with
Do Until .ReadyState = 4:DoEvents:Loop
Do While .Busy:DoEvents:Loop
End with
End Sub
I am in need of assistance. I am trying to write a VBA script that would take the value in column A and place it on an online form in an input element with no ID but the name ("OldUrl"). Then the VBA script would take the value in the adjacent cell in column B and place that in the same form ("digiSHOP") in the input field named ("NewUrl").
The form is on a secure server however I have gotten as far as the window pulling up and the form selected. I am having trouble finding a way to target the input field since they have no ID. Below is my code and thank you for your help.
Sub Redirect()
Dim IE As Object
Dim doc As Object
Dim form As Object
Dim OldURL As Object
Dim NewURL As Object
Set IE = CreateObject("InternetExplorer.Application")
With IE
.Visible = True
.Navigate "https://...."
Do Until .ReadyState = 4: DoEvents: Loop
Set doc = IE.Document
Set form = doc.forms("digiSHOP")
Set OldURL = doc.getElementById("OldUrl")'Error occurs here. Element has no ID
OldURL.Value = Range("A2")
Set NewURL = doc.getElementById("NewUrl")
NewURL.Value = Range("B2")
form.submit
Do Until .ReadyState = 4: DoEvents: Loop
Do While .Busy: DoEvents: Loop
End With
End Sub
Also I wasn't sure how to target the entire column and loop it therefore the Value is set to the cell A2. This was more to test the script.
Sub Redirect()
Dim IE As Object
Dim doc As Object
Set IE = CreateObject("InternetExplorer.Application")
With IE
.Visible = True
.Navigate "https://...."
Do Until .ReadyState = 4: DoEvents: Loop
With .Document.forms("digiSHOP")
.elements("OldUrl").Value = Range("A2")
.elements("NewUrl").Value = Range("B2")
.submit
End With
Do Until .ReadyState = 4: DoEvents: Loop
Do While .Busy: DoEvents: Loop
End With
End Sub
这篇关于Excel VBA脚本使用IE预填网上表格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!