+ Reply to Thread
Results 1 to 7 of 7

Look up company name in cell and return address from google using API

  1. #1
    Registered User
    Join Date
    08-26-2014
    Location
    A Sea Container
    MS-Off Ver
    2016
    Posts
    14

    Look up company name in cell and return address from google using API

    Hi all,

    I am trying to use a code I found online to look up a company name from a cell in my excel workbook and return the address of that company from the google search result. I have obtained a google API key but the code is getting stuck on the first line:

    Please Login or Register  to view this content.
    If I comment out that line of code it errors on the next one. I'm not at all familiar with this type of code so I'm not even sure where to begin. Any help greatly appreciated.

    Thank you.
    Last edited by radioactivity; 12-06-2021 at 01:28 AM.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,720

    Re: Look up company name in cell and return address from google using API

    You are using a number of data types that are not built into VBA. You will have to set a reference for those. Have you done that? From the VBA development window:

    • Tools
    • References
    • Find "Microsoft XML, v 6.0" and check the box


    This a sub but the Sub declaration is missing from your code. Can you provide the first line of code? It starts with Private Sub, Public Sub, or just Sub.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    08-26-2014
    Location
    A Sea Container
    MS-Off Ver
    2016
    Posts
    14

    Re: Look up company name in cell and return address from google using API

    Quote Originally Posted by 6StringJazzer View Post
    You are using a number of data types that are not built into VBA. You will have to set a reference for those. Have you done that? From the VBA development window:

    • Tools
    • References
    • Find "Microsoft XML, v 6.0" and check the box


    This a sub but the Sub declaration is missing from your code. Can you provide the first line of code? It starts with Private Sub, Public Sub, or just Sub.
    Hi Jeff, thanks for your help. I enabled the Microsoft XML, v 6.0 reference and am not getting errors in the code now but nothing happens when I run the sub.

    Here is the full code:

    Please Login or Register  to view this content.

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,720

    Re: Look up company name in cell and return address from google using API

    Please Login or Register  to view this content.
    The variable output is not declared, and it is never given a value. This is not the only problem but I saw this right away. I am going to see if I can run your code.

  5. #5
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,720

    Re: Look up company name in cell and return address from google using API

    Please Login or Register  to view this content.
    This will hide all errors. You don't want to use this unless you have something very specific in mind that you are trying to manage.

  6. #6
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,720

    Re: Look up company name in cell and return address from google using API

    The code has the comment
    Please Login or Register  to view this content.
    but you did not not replace spaces with +.
    Please Login or Register  to view this content.

    I got an error on the following line but I am not familiar with the object structure so I am a bit stuck:
    Please Login or Register  to view this content.
    However, I tried putting your query directly into a web query and got this response:
    Please Login or Register  to view this content.
    This suggests that your API key is not properly registered, or billing is not set up for it.

  7. #7
    Registered User
    Join Date
    08-26-2014
    Location
    A Sea Container
    MS-Off Ver
    2016
    Posts
    14

    Re: Look up company name in cell and return address from google using API

    Hi Jeff, thank you so much for putting so much effort into testing and explaining this code to me. You were right, I had not registered my billing account with Google. I made the changes to the query = cell.Value, commented out the 'On Error Resume Next' and registered my billing account with google, however I'm still getting nothing when I run the code. I did play around with it a bit and got the same error on
    Please Login or Register  to view this content.
    but then I reset the code and now nothing happens again. Sorry for relying so heavily on you here but I'm completely stumped! Really appreciate all your help!

+ 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. [SOLVED] How to collect Name and Company from Email Address?
    By AaruJaan in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 01-26-2021, 12:29 PM
  2. get company number and address from uk companies house
    By tek9step in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-21-2021, 07:25 AM
  3. Replies: 1
    Last Post: 12-10-2020, 06:28 PM
  4. Using a button to Open Google Maps referencing an address from a worksheet cell
    By IndigoNW in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-25-2019, 08:59 PM
  5. Split Company Name and Address into multiple Cells
    By snuffnchess in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-19-2019, 10:02 AM
  6. Pulling company name, street address, city, state, and zip from address
    By UNREAL2K4 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 07-13-2015, 12:53 PM
  7. Search on company name to auto input company address
    By jamie.c in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-12-2009, 12:38 PM

Tags for this Thread

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