IE.document.getElementbyID
を使用してIEの検索ボックスにテキストを読み込む際に問題があります。これまで使用していたコードを含めています。私はここで何かを逃していると確信しています。これは、あなたがキャッチしようとしているオブジェクトが"data-automation-id"
属性を持つ、ID
属性を持っていない私はここに実行時エラー '424':Object Required IE.Document.GetElementById iframe内のテキストボックス
<iframe tabindex="-1" id="WorkdayApp" src="javascript:""" style="left: -1000px; top: -1000px; width: 0px; height: 0px; border-top-color: currentColor; border-right-color: currentColor; border-bottom-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-right-width: medium; border-bottom-width: medium; border-left-width: medium; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; position: absolute;">
<input class="gwt-TextBox GPNS02MDDGJ" aria-label="Expanded, multiSelectPrompt, 0 items selected, Use up and down arrows to select. or Type in a search" type="text" placeholder="search" data-automation-id="searchBox"/>
含めていますインラインフレームコード」
Sub workdayrep()
'*******************************
Dim iframe As Object
Dim textbox As Object
'*******************************
Dim IE As InternetExplorer
Set IE = New InternetExplorer
Set iframe = IE.document.getElementById("WorkdayApp")
Set textbox = iframe.contentWindow.document.getElementById("searchBox")
IE.Visible = True
IE.navigate "https://wd.workday.com/142.htmld"
Application.StatusBar = "Page Loading"
'Do While IE.Busy
' Application.Wait DateAdd("s", 1, Now)
' Loop
Application.Wait Now + TimeValue("00:00:10")
textbox.Value = "TEST"
' Application.StatusBar = "Check"
End Sub
私はそれをテストすることはできませんが、私はまだIE.BusyそれともIE.ReadyState <ながらあなたは '使用することをお勧め> 4:DoEvents関数:Wend'代わりに'アプリケーションの。 Wait' ...また、IE.document.getElementById( "searchBox") 'はただ1つのオブジェクトを返しますか?ただの 'stop'か、ブレークポイントを経由して、あなたの' getElementById'前に、あなたのコードを停止し、あなたの ''直接IE.document.getElementById(「検索ボックス」)、「時計」に入れて、それが返されないかどうか確認...私は単純にしないでくださいあなたが '.Value'を介して直接アクセスできると思います –
私はちょうど私がテキストを入力しようとしているサイトのコードを見ていますそれはiframe内 –
時にはIEの自動化VBAで少し奇妙なことができます。 Value = SV'それを試してみると、私はあなたの検索値を文字列 'Dim SV as String'' SV =" TEST "'で直接定義してみることができます。私の最近のウェブスクレイピングプロジェクトでこれをたくさんしなければならなかった。 –