Page 1 of 2 12 LastLast
Results 1 to 10 of 18
Like Tree1Likes

Click Link on Webpage using VBA

This is a discussion on Click Link on Webpage using VBA within the Excel Questions forums, part of the Question Forums category; Hi all, I'm trying to click a link on a webpage I already have open. For example say I have ...

  1. #1
    New Member
    Join Date
    Jan 2008
    Posts
    9

    Question Click Link on Webpage using VBA

    Hi all,

    I'm trying to click a link on a webpage I already have open.

    For example say I have google.com open and I wanted to click 'Images' at the top of the page without using the code...

    ie.navigate("http://images.google.com/imghp?hl=en&tab=wi")
    (I can't use this code b/c the page i'm trying to access requires I click the link)


    Is there a way to identify the link on the page by its name and then "click" it?

    I've been trying to find code for this all over the place, and it seems impossible to find it...if any one can offer some help I'd appreciate it.

    Thanks in Advance

  2. #2
    Board Regular Norie's Avatar
    Join Date
    Apr 2004
    Location
    Stirling
    Posts
    66,073

    Default Re: Click Link on Webpage using VBA

    Sorry but I don't understand.

    You seem to be saying you don't want code but then appear to want code.

    What's the problem with using Navigate?
    If posting code please use code tags.

  3. #3
    New Member
    Join Date
    Jan 2008
    Posts
    9

    Default Re: Click Link on Webpage using VBA

    I need VBA code. I just can't use the ie.navigate("www.website.com") I need some other work around because if I just try to navigate to the page it says it has expired and I need to re-login. So i actually have to click it.

    I'm wondering if VBA has a way to find the hyperlink and click it.

  4. #4
    Board Regular Norie's Avatar
    Join Date
    Apr 2004
    Location
    Stirling
    Posts
    66,073

    Default Re: Click Link on Webpage using VBA

    There probably is a way to 'click' the link, but I've got a feeling that you might end up with the same result. ie page expired

    I don't see why you think clicking the link would make any difference.
    If posting code please use code tags.

  5. #5
    New Member
    Join Date
    Jan 2008
    Posts
    9

    Default Re: Click Link on Webpage using VBA

    Well I had tried to use Shellobjects to passkeys to IE and did get a link to open that way. However, I have to navigate through several pages, and the last page actually needs to be clicked I simply can not pass 'Tab' commands to it and hit enter.

    Also in general this seems like a very sloppy way of trying to open a link on a page.

    Is there any way using VBA to identify links on a page and then click them?

    Thanks

  6. #6
    Board Regular Norie's Avatar
    Join Date
    Apr 2004
    Location
    Stirling
    Posts
    66,073

    Default Re: Click Link on Webpage using VBA

    You can definitely automate IE using VBA, and you should probably avoid using anything like SendKeys.

    Not only is it flaky, it's not needed.

    But I'm afraid the main issue with this sort of thing is how the webpage/site has been designed.

    It's almost impossible to help without at least a valid URL and more information on what you are actually trying to achieve.
    If posting code please use code tags.

  7. #7
    Board Regular
    Join Date
    Oct 2007
    Posts
    3,089

    Default Re: Click Link on Webpage using VBA

    Quote Originally Posted by mojo215 View Post
    I'm trying to click a link on a webpage I already have open.

    For example say I have google.com open and I wanted to click 'Images' at the top of the page without using the code...
    So do you have IE open and it wasn't opened by VBA? If so, use Shell.Windows to find the IE window, set it to an InternetExplorer object and then loop through the IE.Document.Links() array looking for innerText = "Images". Then it's IE.Document.Links(x).Click to click the link.
    VikP likes this.

  8. #8
    New Member
    Join Date
    Jan 2008
    Posts
    9

    Default Re: Click Link on Webpage using VBA

    I wish I could supply the URL, its business related and requires a login. If you have some base code for finding a link I'm sure that would be useful and I could try and adapt that.

    As in the example I had above...

    I have www.google.com open

    Now I want to Click the Hyperlink "Images"
    How could this be achieved?


    Also another possible work around if they above isn't possible...a way to move the mousepointer to specific part of the screen and then pass a left click through that would work fine for me...

    I dunno I've just been at my wits end trying to work this out.

    Thanks for the help

  9. #9
    New Member
    Join Date
    Jan 2008
    Posts
    9

    Thumbs up Re: Click Link on Webpage using VBA

    thanks John I'll give that a shot and let you know.

  10. #10
    Board Regular
    Join Date
    Oct 2007
    Posts
    3,089

    Default Re: Click Link on Webpage using VBA

    Search for the terms in my post - there are plenty of examples. And answering my question would make things clearer.

Page 1 of 2 12 LastLast

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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


DMCA.com