Option Explicit '待ちD Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Public Sub Google検索() Dim 検索文字 As String 検索文字 = Worksheets("Sheet1").Range("A2").value ' WebDriverの開始 (Edge) Dim Driver As New WebDriver 'Driver.Edge "path\to\msedgedriver.exe" Driver.Edge "C:\Tool\msedgedriver\msedgedriver.exe" ' ブラウザを開く Driver.OpenBrowser ' Googleへ移動 Driver.Navigate "https://www.google.co.jp/?q=selenium" ' 検索テキストボックスを取得 Dim searchInput Set searchInput = Driver.FindElement(By.Name, "q") ' テキストボックスの値を取得 Debug.Print searchInput.GetValue ' テキストボックスに値を入力 ' searchInput.SetValue "yomoda soba" searchInput.SetValue 検索文字 DoEvents ' Sleep しているときに、画面を書き換えできるように、OS に制御を渡す。 Sleep (1000) ' 検索ボタンのクリック Driver.FindElement(By.Name, "btnK").Click ' 再読み込み - ヘルパーメソッドを提供していない場合でも、ドライバーコマンドを直接実行することができます Driver.Execute Driver.CMD_REFRESH End Sub