473,321 Members | 1,622 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

Invalid procedure call or argument

1
Expand|Select|Wrap|Line Numbers
  1. Public Sub ExcelGoogleSearch()
  2.  
  3. Dim searchWords As String
  4.  
  5. With Sheets("Sheet1")
  6. RowCount = 1
  7. Do While .Range("A" & RowCount) <> ""
  8. searchWords = .Range("A" & RowCount).Value
  9.  
  10. ' Get keywords and validate by adding + for spaces between
  11. searchWords = Replace$(searchWords, " ", "+")
  12.  
  13. ' Obtain the source code for the Google-searchterm webpage
  14. search_url = "http://www.google.com/search?hl=en&q=" & searchWords & "&meta="""
  15. Set search_http = CreateObject("MSXML2.XMLHTTP")
  16. search_http.Open "GET", search_url, False
  17. search_http.send
  18. results_var = search_http.responsetext
  19. Set search_http = Nothing
  20.  
  21. ' Find the number of results and post to sheet
  22. pos_1 = InStr(1, results_var, "resultStats>", vbTextCompare)
  23. pos_2 = InStr(3 + pos_1, results_var, ">", vbTextCompare)
  24. pos_3 = InStr(pos_2, results_var, "<nobr>", vbTextCompare)
  25. NumberofResults = Mid(results_var, 1 + pos_2, (-1 + pos_3 - pos_2))
  26. Range("B" & RowCount) = NumberofResults
  27. RowCount = RowCount + 1
  28. Loop
  29. End With
  30. End Sub
Hi all,

I was wondering if these codes are correct because I cannot run the macros
Aug 30 '11 #1

✓ answered by ADezii

I would imagine that you woould need to build the List of KeyWords in a String prior to passing this String to the Google Search Engine, such as:
Expand|Select|Wrap|Line Numbers
  1. Dim searchWords As String
  2. Dim RowCount As Integer
  3.  
  4. With Sheets("Sheet1")
  5.   RowCount = 1
  6.     Do While .Range("A" & RowCount) <> ""
  7.       searchWords = searchWords & .Range("A" & RowCount).Value & "+"
  8.         RowCount = RowCount + 1
  9.     Loop
  10. End With
  11.  
  12. 'Remove Trailing '+' and display
  13. MsgBox Left$(searchWords, Len(searchWords) - 1)
which would produce a Keyword String such as:
Expand|Select|Wrap|Line Numbers
  1. One+Two+Three+Four+Five+Siux+Seven +Eight+Nine+Ten

1 915
ADezii
8,834 Expert 8TB
I would imagine that you woould need to build the List of KeyWords in a String prior to passing this String to the Google Search Engine, such as:
Expand|Select|Wrap|Line Numbers
  1. Dim searchWords As String
  2. Dim RowCount As Integer
  3.  
  4. With Sheets("Sheet1")
  5.   RowCount = 1
  6.     Do While .Range("A" & RowCount) <> ""
  7.       searchWords = searchWords & .Range("A" & RowCount).Value & "+"
  8.         RowCount = RowCount + 1
  9.     Loop
  10. End With
  11.  
  12. 'Remove Trailing '+' and display
  13. MsgBox Left$(searchWords, Len(searchWords) - 1)
which would produce a Keyword String such as:
Expand|Select|Wrap|Line Numbers
  1. One+Two+Three+Four+Five+Siux+Seven +Eight+Nine+Ten
Aug 30 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: john | last post by:
Ran Windows update tonight. Since then I get this error: HTTP 500.100 - Internal Server Error - ASP error Internet Information Services ...
6
by: mork | last post by:
I am so frustrated - any help is appreciated. When trying to use common functions like Left and/or Mid I get the following error: Run-time Error '5': Invalid Procedure Call or Argument In my...
2
by: Zoury | last post by:
Hi there! I'm using a COM component from my C# application and I can't get it to work properly. I get a COMException (Invalid procedure call or argument) on this line : //***...
5
by: Matt | last post by:
I am receiving the following error from the simple script below. This works fine from a .NET form but when I access the dll from a Classic ASP page it fails. Microsoft VBScript runtime error...
5
by: Eric | last post by:
I run a program which read emails from a text file. There is some thing invalid in one or more text file. When program is busy doing parsing it shows that error and process stop. I dont know which...
0
by: AparnaKulkarni | last post by:
Hello, I m working with Templates in MS Word. I have established the user Template locations in Word with ".dot" file But after that I m getting error as "Invalid procedure call or argument...
6
by: HaggardSmurf | last post by:
Private Sub Downloader1_DownloadComplete(MaxBytes As Long, SaveFile As String) If MsgBox("Donwnload Finished. Would you like to install now?", vbInformation + vbYesNo, "Blue Cherry Media...
1
by: PurpleWitch | last post by:
Hi there I'm using an Access 2000 DB on Office 2000. The following Pivot Table worked fine 2 days ago, but no I'm getting the "Invalid Procedure Call or Argument" error when using Pivot Table...
25
by: dennijr | last post by:
ok, shell always used to be easy for me, now its starting to get annoying cause i dont know wats wrong heres the simplist code possible: Private Sub IExplorer_Click() a = Shell("C:\Program...
1
by: PrakashN | last post by:
Hai I have done validation for mandatory fields when adding a record in a Button click event.if i click that button using shot cut keys without selecting the option, i m receiving...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.