+ Reply to Thread
Results 1 to 18 of 18

Logging onto a web site with Excel using IE

  1. #1
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Logging onto a web site with Excel using IE

    The frustrating thing is that this code used to work until Microsoft "improved" IE.

    The site is proprietary, so that is a hindrance. I get one of the following error messages depending on when I run the code:

    Method Busy of object 'IWebBrowser2' failed.

    or

    Automation error
    Unspecified error

    or

    Automation error
    The Interface is unknown

    the error occurs on: Do While .Busy Or .readyState <> 4

    Here is the full code:
    Please Login or Register  to view this content.
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  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: Logging onto a web site with Excel using IE

    I have noticed lots of issues with IE too... often I have had to add a wait time to ensure the next part of my code will work, it is like interacting with IE is sluggish and somehow the object is not always available. Your code SHOULD work of course, but maybe the loop is too fast and VBA can't address the IE object that quickly? I ended up with this (slower and less efficient, but don't get those errors):

    Please Login or Register  to view this content.
    My 2 second wait time is arbitrary, I chose 2 to be safe... but my application runs automatically at night so I can afford wait times that might be inconvenient in a "Live" scenario
    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 dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Logging onto a web site with Excel using IE

    I got past the initial hurdle and I even added the loop as you suggested and extended it to 10 seconds.

    Now I get "Interface is Unknown" on Set doc = IE.document

    I have defined doc as an object and an HTMLDocument and it doesn't matter. As I said, the code used to work.

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

    Re: Logging onto a web site with Excel using IE

    I see you have a messagebox coming up... did you remove that? does it work with the message box? I just wonder because that would act as ANOTHER wait after the loop last checked the busy state...

    Alternatively, but requires a reference to Microsoft Internet Controls added:

    Change
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    No guarantees this will work, but worth a shot.

  5. #5
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Logging onto a web site with Excel using IE

    The message boxes are removed as I get far enough into the code to execute them. This code has been fighting me line-by-line.

    The code is heavily commented with all the things I tried, but didn't work. Apparently this incantation in combination with late binding works. Thanks for the tip. I now have to move onto the next step" navigating to a "tab" (no, not that kind of tab, but a tab that is on the form that is within the current tab) .

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

    Re: Logging onto a web site with Excel using IE

    I obviously can't see the page and its code, but typically each "Tab" in the form has an ID. For example when I navigate tabs on the program I run overnight, though usually the "next" button takes me through the tabs when submitting data, I sometimes have to go to a specific tab. One of these tabs submits taxes, and after having found the ID for that tab ("TaxTab"), I use this code:
    Please Login or Register  to view this content.
    Last edited by Arkadi; 04-12-2018 at 07:47 AM.

  7. #7
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Logging onto a web site with Excel using IE

    I've eliminated most of the code. I also added in some line breaks to make it legible. Also I had to remove anything that looks like HTML since I can't post Highlighted is the link I want to click. I think this is a "collection" of some kind. I have a vague notion of what collections are, and the specific link I want is a member of it. I tried setting setCustomLinks to an object and when I take the length of that object, it is zero (code posted after HTML).
    Please Login or Register  to view this content.
    This is what I attempt. My understanding is that "length" returns the number of elements. Of course I may be looking at the wrong thing.
    Please Login or Register  to view this content.

  8. #8
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Logging onto a web site with Excel using IE

    I tried your code assuming that the link name is "Device Performance" If I define Lnk as a variant I get a type mismatch error. If I define it as an object, I get an object required error on the set Lnk = line.

    P.S. If I try Set Lnk = doc.getElementByTagName(LinkName) I get an object not supported error message.

    Please Login or Register  to view this content.
    Last edited by dflak; 04-12-2018 at 09:15 AM.

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

    Re: Logging onto a web site with Excel using IE

    "Device Performance" is certainly not the ID, you can't have spaced in an ID

  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: Logging onto a web site with Excel using IE

    If you right-click on a tab, and choose "inspect element", you hopefully would find a section of code that has a link to a javascript action? Something like href="javascript:..." since it looks like the form is javascript based..

    you can use
    Please Login or Register  to view this content.
    to execute what would happen if you clicked on such a tab. It is hard to be more specific since I can't see the site, but maybe it helps you some...

  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: Logging onto a web site with Excel using IE

    Odd tried to edit the above post and got a new post... disregard this one.

  12. #12
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Logging onto a web site with Excel using IE

    @Arkadi - I would show you the results of the inspect element, but when I copy and paste it, it looks nothing like the screen. Also I see hundreds of < script type="text/javascript > most are immediately followed by < /script > How do I know which one to select? Also can you mock up what the syntax would look like. ie.navigate "javacript xyz?" What do I put for xyz?

    I captured what I think are the important part of the inspection: something that references dashboard_page_7_tab and the java script that comes immediately before it about 75 lines above.

    The second picture came out blurry. Here is the line with the javascript

    < script src="res/b_mozilla/common/componentheader.js" type="text/javascript" >< /script >
    Attached Images Attached Images

  13. #13
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Logging onto a web site with Excel using IE

    The unfortunate thing about this effort is that what I call a tab for lack of any other name, the rest of the world thinks I am talking about TAB as in a new window in the same instance of IE - this is making a web search impossible. Is there any other name for this thing?
    Attached Images Attached Images

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

    Re: Logging onto a web site with Excel using IE

    Id be curious what is showing on the <td> above and below the one you expanded...
    It is hard to know exactly how to handle this, since I do have some experience with this but am not an expert either...
    The top row on your second image has an href... I was hoping to see something like that associated with clicking on the tab you want... the xyz in your code would then be the quoted part after the = sign... including the quotes. But it does not look like that applies here, unless the other parts of the page code reveal something.

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

    Re: Logging onto a web site with Excel using IE

    As far as google, you would want to make sure you qualify "tab" by adding "table". For example: vba ie click table tab

  16. #16
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Logging onto a web site with Excel using IE

    Thanks for all the help. I'm converting an old program that worked with a prior version of the BI tool we are now doing. In that version, "tabs" were actually links. If I can break through this barrier then The next page has true links and I could probably adapt my code. I suspect the solution has something to do with that dashboard_page_7_tab, but I don't know how to get to that. GetElementByID doesn't work with it.

    Your other post just came in. I'll look at table tab.

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

    Re: Logging onto a web site with Excel using IE

    I think as well as excel files, you can attach text files... could always put the code into a text file if pasting wasn't working.

  18. #18
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Logging onto a web site with Excel using IE

    I was trying to copy from the inspector to notepad. It wasn't working. You cannot select all and copy.

+ 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. Macro for logging in to website from excel
    By kreal in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-19-2017, 03:44 AM
  2. Logging in to a website using Excel
    By FRIEL in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-10-2011, 11:08 AM
  3. Excel - Logging on to a website
    By jsomer2000 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-15-2011, 12:55 PM
  4. Logging Excel commands used over time
    By antonf in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-21-2009, 03:46 AM
  5. Still Trying to Fix a Data Logging Problem In Excel
    By Cydog in forum Excel General
    Replies: 3
    Last Post: 05-01-2009, 07:29 AM
  6. Excel Logging
    By Nashy19 in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 12-12-2008, 07:27 AM
  7. [SOLVED] DDE Logging Data Loss in Excel
    By PSY_UK in forum Excel General
    Replies: 0
    Last Post: 12-01-2005, 05:10 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