+ Reply to Thread
Results 1 to 7 of 7

Return first search result from Google

  1. #1
    Registered User
    Join Date
    02-21-2013
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    72

    Return first search result from Google

    Hi,

    I'm using the following code to return the first search result from Google and it seems to work quite well. Although, I sometimes encounter a run-time error '91' (Object variable or With block variable not set) when running the code. When I then search the URL in google, no search results show up. Is there a way of skipping that row in VBA if no search results pop up?

    Please Login or Register  to view this content.
    Thanks

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Lightbulb Re: Return first search result from Google


    Hi !

    It depends on the codeline where errors occurs : you must test if object exists !

  3. #3
    Registered User
    Join Date
    02-21-2013
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    72

    Re: Return first search result from Google

    Hi Marc,

    So the error occurs on this line:

    Please Login or Register  to view this content.
    Then when I do a search for that link on google, no search results appear. I was wondering if there was a way of just skipping that row altogether and moving onto the next

  4. #4
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: Return first search result from Google


    Check if objH3 variable is not equal to Nothing in Locals window and if not, so there is no element "A" …

    As I can't test on my side without a cell value for the URL …

  5. #5
    Registered User
    Join Date
    02-21-2013
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    72

    Re: Return first search result from Google

    Thanks Marc.

    I've modified my code and it seems to work now.

    Please Login or Register  to view this content.

  6. #6
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: Return first search result from Google


    Nice !

    Thanks for the rep' !

  7. #7
    Registered User
    Join Date
    09-20-2022
    Location
    new york
    MS-Off Ver
    365
    Posts
    2

    Re: Return first search result from Google

    i get a not defined error on this:"Public Sub InsertPicturesFromWeb()" anyway to fix it? new to this game. ty

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Autoimport Google Image Search Result into Excel
    By awesummusik in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-14-2021, 12:29 PM
  2. [SOLVED] Download all the images as a result of google search
    By YasserKhalil in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 09-02-2015, 07:53 PM
  3. Create Macro to import first Google Search result
    By aolo in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-29-2012, 07:54 AM
  4. Replies: 0
    Last Post: 11-05-2009, 04:47 AM
  5. Help with Google Search Result !
    By zeeshanhashmi in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-08-2009, 12:19 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1