+ Reply to Thread
Results 1 to 14 of 14

Problem with HTML.innertext of loaded webpage

  1. #1
    Registered User
    Join Date
    11-27-2015
    Location
    Belgium
    MS-Off Ver
    2013
    Posts
    6

    Problem with HTML.innertext of loaded webpage

    Hi, i'm really new here and really not familiar with VBA.

    I have been searching a couple of days to solve this issue:
    My goal is to create an Application in VBA which automatically logins to a Website and then retrieves certain info of several webpages (with the same layout). After this, the info needs to be written to excel. By watching several tutorials I have been able to write this piece of code. I think that my main problem is the fact that I cannot get the HTML code of the page which has loaded after login.

    It also seems that the part with oBrowser.readystate = 3 is causing some problems.
    If anyone could that a look at this, it would mean a lot .

    Please Login or Register  to view this content.

  2. #2
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Problem with HTML.innertext of loaded webpage

    Hi Tyson,

    I'm not sure why you are first looping until the browser is interactive, and then looping again until it is ready.... is it really required? I took out the interactive loop and just made sure the page is loaded, then it seemed to work fine... let me know if this version below works for you? I modified the structure of the final loop a bit.

    Please Login or Register  to view this content.
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  3. #3
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Problem with HTML.innertext of loaded webpage

    Nep, it is not going to work. The error trapping appears to make it work.
    You need to remove all of them and see in which line the code errors.

    It is also a good idea to declare all your variables.
    a = the_element.name

    what is a supposed to be?

    It is difficult to suggest any solution, since the site has access rights.

  4. #4
    Registered User
    Join Date
    11-27-2015
    Location
    Belgium
    MS-Off Ver
    2013
    Posts
    6

    Re: Problem with HTML.innertext of loaded webpage

    I watched https://www.youtube.com/watch?v=qJPoeIZ0pWM as a guide to get the innertext of the page loaded. He just said it was necessary to have oBrowser.readystate = 3, but didn't really mention the reason why.

    I've tried the code with Arkadi's modifications, but i'm still not able to get the innertext of the page loaded.
    I'v made an account with e-mail: [email protected] and password: pass123. This should give you access to the site.

    When I add the code below after Next input_element, I get an infinite loop, which probably suggest that the this causes always the same error.
    Please Login or Register  to view this content.
    Thanks for your quick responses!
    Last edited by tyson_t; 11-27-2015 at 11:07 AM.

  5. #5
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Problem with HTML.innertext of loaded webpage

    I spent half an hour as I was unable to log-in and tearing my hair apart, only to find out there is a typo in your password

    tbpassword
    P is an upper case, not lower.
    This gives you access to the site, and copies the dom doc in to A1-just to test it is working.

    Please Login or Register  to view this content.
    Last edited by AB33; 11-27-2015 at 11:45 AM.

  6. #6
    Registered User
    Join Date
    11-27-2015
    Location
    Belgium
    MS-Off Ver
    2013
    Posts
    6

    Re: Problem with HTML.innertext of loaded webpage

    I've made just a little adjustment to get it to the next page. But i'm still getting the same innertext as the login page.

    These are the used references just in case that it is wrong;
    - Visual basic for Applications
    - Microsoft Excel 15.0 Object Library
    - OLE automation
    - Microsoft Forms 2.0 Object Library
    - Microsoft Office 15.0 Object Library
    - Microsoft HTML Object Library

    i'm using excel 2013 and Internet explorer 11

    The altruistic force is great here, i'm already really thankful for this :p
    Hope you still have some hair.

    Please Login or Register  to view this content.
    Last edited by tyson_t; 11-27-2015 at 12:59 PM.

  7. #7
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Problem with HTML.innertext of loaded webpage

    If your connection is slower then you may be getting the innertext too soon after clicking... try adding the loop after the click like this:

    Please Login or Register  to view this content.

  8. #8
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Problem with HTML.innertext of loaded webpage

    Arkadi has spotted an error on my last line.
    Please Login or Register  to view this content.
    Well done!Arkadi

  9. #9
    Registered User
    Join Date
    11-27-2015
    Location
    Belgium
    MS-Off Ver
    2013
    Posts
    6

    Re: Problem with HTML.innertext of loaded webpage

    Still the same... . Do you get a msgbox which is different from this one?
    picture.jpg

  10. #10
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Problem with HTML.innertext of loaded webpage

    Yes... I get the content of the page AFTER login

  11. #11
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Problem with HTML.innertext of loaded webpage

    Have you tried using F8 to step through each line, and does the web page open and then login successfully? if you do that manually, do you get a different result?

  12. #12
    Registered User
    Join Date
    11-27-2015
    Location
    Belgium
    MS-Off Ver
    2013
    Posts
    6

    Re: Problem with HTML.innertext of loaded webpage

    I got the right result when I try to run it with f8 manually. But when i press play I get the msgbox of the login page. Maybe I should just try it on a different computer. Who knows.... :p

  13. #13
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Problem with HTML.innertext of loaded webpage

    Sounds like the code is too fast for your internet... but strange with the extra loop for ie.readystate checking.... you could try adding
    Please Login or Register  to view this content.
    to wait 5 seconds AFTER clicking the button and before reading the innertext.

  14. #14
    Registered User
    Join Date
    11-27-2015
    Location
    Belgium
    MS-Off Ver
    2013
    Posts
    6

    Re: Problem with HTML.innertext of loaded webpage

    Thanks a lot! It is working

+ 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] Run a Macro from a Hyperlink in an Html file loaded in the Webbrowser on a Userform!
    By EchoPassenger in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-26-2015, 04:20 PM
  2. Disable the Open Button in the Excel template loaded in Webpage
    By Rem0ram in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-07-2014, 04:31 AM
  3. Pass entire HTML source for webpage to string using Excel VBA
    By stuht in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-03-2013, 09:48 AM
  4. GET HTML DATA FROM WEB PAGE using DOCUMENT.BODY.INNERTEXT
    By smitch1065 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-01-2013, 02:16 PM
  5. Help in getting to full HTML source code for webpage via Excel VBA
    By stuht in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-07-2013, 05:41 PM
  6. extract information from webpage html tags to excel
    By b.hill in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-06-2012, 01:24 AM
  7. Get html table from webpage to excel
    By prayami in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-28-2008, 05:38 AM

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