+ Reply to Thread
Results 1 to 10 of 10

Get HTML Code into String from Newly clicked webpage (i.e. URL doesn't change)

  1. #1
    Registered User
    Join Date
    03-06-2013
    Location
    California
    MS-Off Ver
    Excel 2010
    Posts
    3

    Get HTML Code into String from Newly clicked webpage (i.e. URL doesn't change)

    Hi guys,

    So I'm trying to get the HTML source code from a website, except the website URL never changes. This is what I have so far/what I need help with:
    Please Login or Register  to view this content.
    So VBA clicks on the button that I want, and InternetExplorer goes to the new webpage (this part of my code works correctly). The URL, however, never changes. So when I try to get the HTML source code of the new webpage through VBA, VBA gets the HTML source from the original webpage, not the new webpage that I want.

    Is there a way to get the source code from the new webpage, not the original webpage?

    Thanks!
    Last edited by Leith Ross; 03-06-2013 at 11:04 PM. Reason: Added Code Tags

  2. #2
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: Get HTML Code into String from Newly clicked webpage (i.e. URL doesn't change)

    Hi,

    Its just a typo.

    Dim strURI, htmlDOC As String

    struURI = "....somewebsite.com"
    Happy Computing ,

    Xlbiznes.

    To show your appreciation please click *

  3. #3
    Registered User
    Join Date
    03-06-2013
    Location
    California
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Get HTML Code into String from Newly clicked webpage (i.e. URL doesn't change)

    Thanks for that. It's actually correct in my vba code, I just accidentally copied it over incorrectly.

    Still, after fixing that mistake I still have the same problem as above. Any thoughts?

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Get HTML Code into String from Newly clicked webpage (i.e. URL doesn't change)

    I'm guessing the reason you get the HTML for the previous page is because you don't wait for the new page to load.

    You ned something between clicking the button and getting the HTML to allow for the page to load, take a look at using ReadyState to check if the page has loaded.
    If posting code please use code tags, see here.

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

    Re: Get HTML Code into String from Newly clicked webpage (i.e. URL doesn't change)

    Without seeing the page it's difficult to say. IF the url never changes, it's often down to 1 of two things:

    1. The data you are after is in a frame on the page - this is just a window to another webpage, so it's like a page within a page and the data is there rather than on the page you are on
    2. The data is built/loaded via javascript so isn't in the source of the page. If you use something like inspect element on Chrome or developer tools in IE, you should still see the elements you are looking for though

  6. #6
    Registered User
    Join Date
    03-06-2013
    Location
    California
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Get HTML Code into String from Newly clicked webpage (i.e. URL doesn't change)

    I don't believe the site uses frames, but I could be mistaken. I'll look into the second item. Here is what I am exactly trying to do (with the website included). I hope this helps:
    Please Login or Register  to view this content.
    Last edited by Leith Ross; 03-07-2013 at 07:27 PM. Reason: Added Code Tags

  7. #7
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Get HTML Code into String from Newly clicked webpage (i.e. URL doesn't change)

    Hello bcbc123,

    To help resolve this issue, copy the page source before and after. Post both files as text files for review. There is nothing in the page source that isn't public.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  8. #8
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Get HTML Code into String from Newly clicked webpage (i.e. URL doesn't change)

    Try repeating this code after clicking the button.
    Please Login or Register  to view this content.
    Also, lose the () around htmlDoc.

  9. #9
    Registered User
    Join Date
    12-03-2008
    Location
    Monterrey, Mexico
    Posts
    3

    Re: Get HTML Code into String from Newly clicked webpage (i.e. URL doesn't change)

    Hello

    How I send an ENTER keystroke to the Internet explorer page?

    I tried the code and it works like a charm, but there is not a button to click, I have to push ENTER key in the keyboard in order to make the page perform the request.

    Thanks in advance.

  10. #10
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Get HTML Code into String from Newly clicked webpage (i.e. URL doesn't change)

    Welcome to the Forum.

    Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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