+ Reply to Thread
Results 1 to 22 of 22

Using wildcards to find hyperlink in a website

  1. #1
    Forum Contributor
    Join Date
    08-02-2012
    Location
    Austria
    MS-Off Ver
    Excel 2007
    Posts
    457

    Using wildcards to find hyperlink in a website

    Hi all,

    I'm trying to find some type of wildcard that I could use to press a wild hyperlink in a page. The name of the hyperlink is shown in the website correct, but in the html code, there are some numbers behind it and I can't select it with the below code. Is it possible to use something like a wildcard with it "GoHere*" to find a word that starts with Gohere ? when finding it in the html code, is shows like this GoHere188393027373839
    GoHere749305045434


    Please Login or Register  to view this content.
    All help will more than welcome :-)

    Greetings.

  2. #2
    Forum Contributor
    Join Date
    08-02-2012
    Location
    Austria
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: Using wildcards to find hyperlink in a website

    Hi all,

    I did check this again at work this morning. The code that I use works if I add the whole name in it. Looking better at the html page, the name is something like this: Name_123456789_a_id
    so when I use the below code:
    Please Login or Register  to view this content.
    It works, if I try it like this:

    Please Login or Register  to view this content.
    I don't get nothing and the code hangs (run time error 91, Object variable or with Block variable not set). What can I do to get a wildcard working?

    Greetings.

  3. #3
    Forum Contributor
    Join Date
    08-02-2012
    Location
    Austria
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: Using wildcards to find hyperlink in a website

    Hi all,

    I have one more question. This will be used in a loop and the part that I try to click, will change every loop. So it will take the names of a list in a excel sheet. So if I have the loop and the next i is a different value, how can I pass this value in the "getElementById:? Could it be like
    Please Login or Register  to view this content.
    ?

    Greetings.

  4. #4
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Using wildcards to find hyperlink in a website

    You can't, wildcards don't work in getElementById, you'd need to get by either the class name or tag and loop through and check against the id property

  5. #5
    Forum Contributor
    Join Date
    08-02-2012
    Location
    Austria
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: Using wildcards to find hyperlink in a website

    Hi Kyle123,

    It is a link in a table row. It is like this:
    HTML Code: 
    So no clue how to use it. If there is a second one, it will have the same name, but the number behind the name would be different.
    For me it is important the click if there is only one, if there are 2, to mark it an go the the next i in the loop.

    Greetings.

  6. #6
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Using wildcards to find hyperlink in a website

    So why can't you loop through the table rows and check the id of each hyperlink?

  7. #7
    Forum Contributor
    Join Date
    08-02-2012
    Location
    Austria
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: Using wildcards to find hyperlink in a website

    Hi,

    I would like to, but don't know how to do this. My knowledge is just to simple and all the code I can get is by finding it with google or some one manage to answer my silly vba questions.

    Greetings.

  8. #8
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Using wildcards to find hyperlink in a website

    What you've posted is not valid html, is that actually what's in the page?

  9. #9
    Forum Contributor
    Join Date
    08-02-2012
    Location
    Austria
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: Using wildcards to find hyperlink in a website

    Hi,
    As it is an intranet site, I can't share it. I know that it makes it only harder to get a solution for it.
    Maybe some simple code that will scan the intranet site and show all the hyper links in side a given table?
    In that table the search is returned and then you can see for 99% only one link, but it is rare and there could be 2 hyperlinks. (actually there is a second to the right of each, this one goes to different part of the intranet page.

    Greetings.

  10. #10
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Using wildcards to find hyperlink in a website

    Something like:
    Please Login or Register  to view this content.
    Will allow you to iterate through all the a tags in a given table

  11. #11
    Forum Contributor
    Join Date
    08-02-2012
    Location
    Austria
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: Using wildcards to find hyperlink in a website

    Hi,

    I got it :-)
    It is the 7th link. can I just click that one by adding a reference to it?

    Greetings.

  12. #12
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Using wildcards to find hyperlink in a website

    Just click it in the loop, you already have a reference to it

  13. #13
    Forum Contributor
    Join Date
    08-02-2012
    Location
    Austria
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: Using wildcards to find hyperlink in a website

    Hi,

    Sounds great, but no clue how to do it. Can you give me a hint?

    Greetings.

  14. #14
    Forum Contributor
    Join Date
    08-02-2012
    Location
    Austria
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: Using wildcards to find hyperlink in a website

    Hi,

    One more little thing.
    there should be like 9 links in this case, if there would be 10 or more, it should step out of the loop and continue with the next action, is that possible?

    Greetings.

  15. #15
    Forum Contributor
    Join Date
    08-02-2012
    Location
    Austria
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: Using wildcards to find hyperlink in a website

    Hi,

    I got it,

    I just added:
    Please Login or Register  to view this content.
    and it did the trick.
    Now i just need it to make sure if there is one more link than normally, not to click it :-)

    Greetings.

  16. #16
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Using wildcards to find hyperlink in a website

    Well yes, just put a counter in the loop, if it exceeds 9 exit.

    I don't automate internet explorer, but I would assume something like:
    Please Login or Register  to view this content.

  17. #17
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Using wildcards to find hyperlink in a website

    Quote Originally Posted by Megatronixs View Post
    Hi,

    I got it,

    I just added:
    Please Login or Register  to view this content.
    and it did the trick.
    Now i just need it to make sure if there is one more link than normally, not to click it :-)

    Greetings.
    Don't do that, web pages change all the time and this is far too fragile. It may be quite likely that the link you want may not always be at 7

  18. #18
    Forum Contributor
    Join Date
    08-02-2012
    Location
    Austria
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: Using wildcards to find hyperlink in a website

    Hi,
    The post nr 16 will click all the links, that will get messy as I will not be able to have clicked the only one I want :-(

    Any solution for if there are 10 links?

    (sorry for so many questions, but it really hard to do it with not to much vba knowledge)

    Greetings.

  19. #19
    Forum Contributor
    Join Date
    08-02-2012
    Location
    Austria
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: Using wildcards to find hyperlink in a website

    Hi (sorry, me again)

    If I want to get the tab index, how could I reuse the above code (the one that finds all the links)?
    I want to click on this button:
    HTML Code: 
    Greetings.

  20. #20
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Using wildcards to find hyperlink in a website

    The post nr 16 will click all the links, that will get messy as I will not be able to have clicked the only one I want :-(
    Like I told you, you need to check the properties of the current tag, access its id and see if it matches the pattern you are looking for.

  21. #21
    Forum Contributor
    Join Date
    08-02-2012
    Location
    Austria
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: Using wildcards to find hyperlink in a website

    Hi,

    the problem is that the link does not have the same name. It is just a text that has an hyperlink attached to it. This means when I click on the text, it will follow the link.
    So I can't check the properties and then know that is the one :-(
    The Intranet page did not change the look for the last 3 years (the time I try to make this work). The only thing that could change is if there will be more than 9 hyperlinks.
    If I'm able to count the hyperlinks, than I can tell the code to continue, or stop and go to the next name in the loop.

    Hope you can help with that :-)

    Greetings.

  22. #22
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Using wildcards to find hyperlink in a website

    Then just check the number of elements in Links - so how do you know if you should click it or not?

    The look of the webpage can have nothing to do with the html properties

+ 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. Hyperlink to a website search- inserting code to reference one cell.
    By taidog12 in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 09-14-2014, 05:09 PM
  2. Replies: 3
    Last Post: 04-19-2013, 03:38 PM
  3. Copy Hyperlink From Website To Excel Spreadsheet Not Working
    By AshleyExcel in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 03-05-2013, 07:29 AM
  4. HYPERLINK("website/"Cell.Text"website, A4)
    By keepstar in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-17-2010, 05:17 PM
  5. Wildcards - Find & Replace
    By zero760 in forum Excel General
    Replies: 9
    Last Post: 07-20-2009, 03:50 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