我有下面的代碼,它完全按照我想要的方式作業。我使用 VBA 在 Excel 彈出視窗中鍵入某個短語以使用 Google 搜索進行搜索。但是,我希望能夠將所有 Excel VBA Google 搜索存盤在同一個 Excel 檔案(同一個/另一個作業表)或另一個檔案中。有誰知道這是否可行?我不知道是應該修改代碼還是以某種方式設定Excel。
Private Const LicenseRegistration As String = " brott och straff"
Private Sub CommandButtonSearch_Click()
Dim query As String
Dim search_string As String
Dim googleChromePath As String
query = InputBox("Enter your keyword", "Google Search")
search_string = Replace(query, " ", " ") & LicenseRegistration
googleChromePath = "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
Shell (googleChromePath & " -url http://google.com/search?q=" & search_string)
With ThisWorkbook.Worksheets("AnotherSheet")
.Cells(.Rows.Count, 1).End(xlUp).Offset(1).Value = search_string
End With
End Sub
彈出一個標題為“Microsoft Visual Basic”的視窗,并顯示:運行時錯誤“9”:下標超出范圍
我完全按照您撰寫的代碼復制并粘貼了代碼,甚至嘗試對其進行了一些修改,但無濟于事。我真的希望你能看到這個鏈接的圖片:https : //drive.google.com/file/d/1me7xBn8jGvtmpRADp5QFUFmR9k2oGzBs/view?usp=sharing
uj5u.com熱心網友回復:
如果您只是想保留 的運行串列search_string,那么您可以使用:
With ThisWorkbook.Worksheets("AnotherSheet") ' change sheet name as needed
.Cells(.Rows.Count, 1).End(xlUp).Offset(1).Value = search_string
End With
在Shell通話之前(甚至之后)。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/398737.html
