Consulting

Results 1 to 12 of 12

Thread: Solved: Google Search

  1. #1
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location

    Solved: Google Search

    Having viciously yoinked some code from Carlos, I appended it to a userform for a quick google search in word. I'd like to increase the responses to 25. but don't really follow the code. I've tried to obvious things (at least to my eyes)
    Last edited by mdmackillop; 03-31-2005 at 02:46 PM. Reason: Replaced Zip file with amended version.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  2. #2
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    Did you try changing this line?
    [vba]
    For i = 0 To 9
    [/vba]

  3. #3
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Yep!
    There were two 9s, so I changed them both to 25
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  4. #4
    Knowledge Base Approver
    The King of Overkill! VBAX Master
    Joined
    Jul 2004
    Location
    Rochester, NY
    Posts
    1,727
    Location
    It looks like the search page it is pulling up only lists results 1-10, even if your google preferences say 100 per page.

    You can make it 25 by making 3 changes
    [vba]' Dim Parcial As String, meuArray(9, 1) As String
    Dim Parcial As String, meuArray(24, 1) As String[/vba]

    [vba]
    'ObjXML.Open "GET", "http://www.google.com.br/search?hl=US&q=" &
    'strSearch & "&meta=", False
    ObjXML.Open "GET", "http://www.google.com.br/search?hl=US&num=100&start=0&q=" _
    & strSearch & "&meta=", False
    'the 100 here could be 25, may be a little quicker

    [/vba]

    [vba]' For i = 0 To 9
    For i = 0 To 24[/vba]

    Should take care of it!

  5. #5
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Thanks Matt,
    Works a treat. I've posted the corrected file in the original question.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  6. #6
    Knowledge Base Approver
    The King of Overkill! VBAX Master
    Joined
    Jul 2004
    Location
    Rochester, NY
    Posts
    1,727
    Location
    After looking a bit more into it, that may cause some problems on results 10-25. You may also want to change the instance of "26" to "25 + Len(i)".
    I'm gonna take a look a little deeper, see if some more modifications can be made as well. I'll let you know either way

  7. #7
    Knowledge Base Approver
    The King of Overkill! VBAX Master
    Joined
    Jul 2004
    Location
    Rochester, NY
    Posts
    1,727
    Location
    OK,
    Just did a bit of work on this one.
    First, I changed the variables to something I understood (no offense, Carlos! I just don't speak much Spanish).
    I was having a few issues with the FollowHyperlink as well, so I changed the method to follow the link (should work with whatever the default browser is--if you have anything aside from IE where you are give it a try and let me know, I only have IE on my work computer).
    Fixed it to display correct amount of results if less than 25 results found
    Fixed it if no results found
    Fixed it to follow correct links when news results come up on the google search (this one threw me off for a while)
    Fixed an apostrophe thing in the response text (was showing up as "& # 3 9 ;" (without the quotes or the spaces between))
    Fixed a few other minor issues that I can't specifically think of right now
    Was going to change the Title/Link parsing to regexp, but with so few results and its not slow anyways, I decided to leave well enough alone

    Give it a whirl, let me know if any issues arise! This was fun
    Matt

  8. #8
    Administrator
    VP-Knowledge Base VBAX Master
    Joined
    Jan 2005
    Location
    Porto Alegre - RS - Brasil
    Posts
    1,219
    Location
    Hi Matt,

    it is Portuguese not Spanish, . No offense taken.
    Best Regards,

    Carlos Paleo.

    To every problem there is a solution, even if I dont know it, so this posting is provided "AS IS" with no warranties.

    If Debugging is harder than writing a program and your code is as good as you can possibly make
    it, then by definition you're not smart enough to debug it.




    http://www.mugrs.org

  9. #9
    Site Admin
    The Princess VBAX Guru Anne Troy's Avatar
    Joined
    May 2004
    Location
    Arlington Heights, IL
    Posts
    2,530
    Location
    Ya know....
    Ya'll do some pretty amazing stuff around here.
    I think it's dang impressive.
    ~Anne Troy

  10. #10
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi Matt,
    Thanks for the help. Somewhere between posting and getting your response, my PC stopped responding to the FollowHyperlinks command and other similar items, refusing to open web pages and so on. However reformatting the C drive and reinstalling everything seems finally to have done the trick, so I can at last try out your solution.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  11. #11
    Administrator
    VP-Knowledge Base VBAX Master
    Joined
    Jan 2005
    Location
    Porto Alegre - RS - Brasil
    Posts
    1,219
    Location
    Wow, sounds like a very radical way to solve it Malcolm,
    Best Regards,

    Carlos Paleo.

    To every problem there is a solution, even if I dont know it, so this posting is provided "AS IS" with no warranties.

    If Debugging is harder than writing a program and your code is as good as you can possibly make
    it, then by definition you're not smart enough to debug it.




    http://www.mugrs.org

  12. #12
    Administrator
    VP-Knowledge Base VBAX Guru MOS MASTER's Avatar
    Joined
    Apr 2005
    Location
    Breda, The Netherlands
    Posts
    3,281
    Location
    Hi mdmackillop,

    Nice piece off work you guys put together!

    If you like to Google from Word there's a nice Hack that you can incorporate in the Taskpane to do the search for you. (And show/follow it in the taskpane as well)

    Check it out: http://hacks.oreilly.com/pub/h/2725

    Enjoy!
    _________
    Groetjes,

    Joost Verdaasdonk
    M.O.S. Master

    Mark your thread solved, when it has been, by hitting the Thread Tools dropdown at the top of the thread.
    (I don't answer questions asked through E-mail or PM's)

Posting Permissions

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