我建立了指示的宏,目的是用值填充一些输入框。值的分配有效,但是一旦我转到另一个框(通过vba)或单击新更改的值(手动,在网页上),它就会重置为原始值。 如何保持这些值不变,以便以后可以按下提交按钮并获得新值?
分配的值示例:“ objCollection(i).Value =” 2000“”
Private Sub Problem()
Dim i As Long
Dim IE As Object
Dim Doc As Object
Dim objElement As Object
Dim objCollection As Object
Dim buttonCollection As Object
Dim valeur_heure As Object
' Create InternetExplorer Object
Set IE = CreateObject("InternetExplorer.Application")
' You can uncoment Next line To see form results
IE.Visible = True
' Send the form data To URL As POST binary request
IE.navigate "webpage.com"
' Wait while IE loading...
While IE.Busy
DoEvents
Wend
Application.Wait (Now + TimeValue("0:00:06"))
IE.document.getElementsByClassName("ng-scope button-standard button-blue
head-action-button")(0).Click
'Set the value to invest
Set objCollection = IE.document.getElementsByTagName("input")
i = 0
While i < objCollection.Length
If objCollection(i).className = "stepper-value ng-pristine ng-untouched ng-valid ng-scope ng-not-empty ng-valid-currency-validator" Then
' Set the value
objCollection(i).Value = "2000"
End If
i = i + 1
Wend
'Open the Stop Loss Window
IE.document.getElementsByClassName("box-tab-value ng-binding ng-scope")
(0).Click
Set objCollection = IE.document.getElementsByTagName("input")
objCollection(2).Value = "-1100"
objCollection(2).Click 'Does not help
objCollection(2).Select 'Does not help
IE.document.getElementsByClassName("stepper-plus")(1).Click
IE.document.getElementsByClassName("stepper-minus")(1).Click
End Sub