0
VBAを使用してウェブページボタンをクリックしたいと思います。私はいくつかのオプションを試しました(下記のコードを見てください)。 の代わりにをクリックした場合、フォーカスを使用すると、プッシュしたいボタンが選択されますが、クリックコマンドは機能しません。他にどんな方法がありますか?以下はVBAでウェブページボタンをクリックする
Sub SubmitInfo()
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.navigate "http://www.ecotransit.org/calculation.en.html"
Do While IE.readyState <> 4: DoEvents: Loop
Application.Wait (Now + TimeValue("0:00:02"))
' 1st option
IE.document.getElementById("calculationBT").Click
' 2nd option
IE.document.getElementsByClassName("formGreenButton")(0).Click
' 3rd option
Set htmlColl = IE.document.getElementsByTagName("input")
Do While IE.document.readyState <> "complete": DoEvents: Loop
For Each htmlInput In htmlColl
If Trim(htmlInput.Type) = "submit" Then
htmlInput.Click
Exit For
End If
Next htmlInput
' 4th option
Set htmlColl = IE.document.getElementsByTagName("input")
Do While IE.document.readyState <> "complete": DoEvents: Loop
For Each htmlInput In htmlColl
If Trim(htmlInput.Value) = "CALCULATE" Then
htmlInput.Click
Exit For
End If
Next htmlInput
End Sub
私は
<input id="calculationBT" type="submit" class="formGreenButton" value="CALCULATE" />
私はこれを自分のコードで試してみて、うまくいかなかった。今まで使っていたものとは違うものをコードで使うことはできますか? (上記のコードを参照してください)。お返事をありがとうございます! – VBAExcel
最初にフォームのフィールドに必要事項を入力し、送信ボタン – area9
@ area9をクリックする必要があります。関連性はありません。 – VBAExcel