+ Reply to Thread
Results 1 to 15 of 15

Use VBA to load a input window (table) in ie?

  1. #1
    Forum Contributor
    Join Date
    04-01-2010
    Location
    USA
    MS-Off Ver
    Office 2021
    Posts
    185

    Use VBA to load a input window (table) in ie?

    I'm trying to automate something using vba and internet explorer.

    I know how to fill in data and click on buttons, but I'm struggling figure out how to click on a java button that I need to in order to fill in the data.

    If I put the mouse over the button it says ""javascript:void();" If I click on it then it brings up a form where I can enter data and hit submit.

    When I look at the source code I see things like:
    Please Login or Register  to view this content.


    I also see references to table in the source code, so my guess is I somehow need to tell it to display the table.

    What am I looking for or what kind of code would I use to display the area I need to put in the input?

    Any help would be greatly appreciated
    Last edited by Leith Ross; 11-08-2011 at 08:23 PM.

  2. #2
    Forum Contributor
    Join Date
    04-01-2010
    Location
    USA
    MS-Off Ver
    Office 2021
    Posts
    185

    Re: Use VBA to load a input window (table) in ie?

    anyone? I'd really like to learn how to do this better

  3. #3
    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: Use VBA to load a input window (table) in ie?

    Hello max3732,

    It would be easier to provide you with an answer if you post the web address. If this is private network then do not bother asking for more information.
    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!)

  4. #4
    Forum Contributor
    Join Date
    04-01-2010
    Location
    USA
    MS-Off Ver
    Office 2021
    Posts
    185

    Re: Use VBA to load a input window (table) in ie?

    In general is there a good website or tutorial about using vba to interact with the internet?

    I have a VBA book and looked at a number of them in the bookstore and don't see anything about this. All I can find online is random forum posts and with people's questions and answers. I'm not really sure what I'm doing.

    As for a a website, the one I had in mind requires you to have a login, but another one that looks similar is:

    http://www.gamespot.com/

    Lets say you want to run code that will put in your email and password, and then let you check your private messages. In order to see the login button you have to have your mouse over the login area on the website. How would you do that with VBA?

  5. #5
    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: Use VBA to load a input window (table) in ie?

    Hello max3732,

    I doubt you will find a VBA book detailing how to control Internet Explorer with VBA. The short answer is yes, you can. Web browsers take you into another dimension of programming. You are using multiple object models: VBA, Internet Explorer, HTML, and DOM. Suffice it to say I can not give a quick tutorial on all this. I can however provide you code that will log you into the site. I will need a couple of hours to write and test the code. Will that work for you?

  6. #6
    Forum Contributor
    Join Date
    04-01-2010
    Location
    USA
    MS-Off Ver
    Office 2021
    Posts
    185

    Re: Use VBA to load a input window (table) in ie?

    Yes, that will work and I greatly appreciate your help. I wouldn't expect you to give a quick tutorial.

    This is something that I'm interested in learning and I'm surprised there's no book or more formal lesson on how to learn this kind of thing. I have a VBA book that I'm going through, but there's almost nothing on this topic.

  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: Use VBA to load a input window (table) in ie?

    Hello max3732,

    What I found even more surprising was the books about Internet Explorer dealt very little with controlling it from VBA .

    I am testing and debugging the code. I should have something working soon.

  8. #8
    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: Use VBA to load a input window (table) in ie?

    Hello max3732,

    This macro will log you into the GameSpot site. You will need to add your email address and password to the macro code. I marked thee in bold text.
    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    04-01-2010
    Location
    USA
    MS-Off Ver
    Office 2021
    Posts
    185

    Re: Use VBA to load a input window (table) in ie?

    Thanks so much for your help. When I launch the code I get an error, as I believe its trying to login before its finished loading the ad that pops up when you first go to the site. There is a button there you have click on to get to the main page or you can wait for the main page to load.

    Is it possible to click on the button that says "click here to continue to gamespot?"

    Also, while trying to learn more about this I found some websites than mention using microsoft internet controls that work with the file "shdocvw.dll" and enables the use of intellisense. I've also seen a number of examples that used the same approach as you and used the "create object" method.

    Is there any particular case where one works better than another?

  10. #10
    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: Use VBA to load a input window (table) in ie?

    Hello max3732,

    I didn't think you were going to post back. I am not sure what is happening on your end. If you can show me which line the error occurs on that would help.

    The Intellisense will only be available to you when the ShDocVw library has been loaded into your VBA project. It is helpful because you don't have to commit to memory the properties, methods, and events associated with the Internet Explorer object. On the downside. it is not good if you plan to use the workbook on different software platforms. Other machines may not be using the same version of the ShDocVw library as you.

    To get around that you can use CreateObject. This will load the ShDocVw library for that machine to create the Internet Explorer application. The draws backs are you don't have Intellisense available nor are the predefined constants for ShDocVw available. In the end, both perform the job the same.

  11. #11
    Forum Contributor
    Join Date
    04-01-2010
    Location
    USA
    MS-Off Ver
    Office 2021
    Posts
    185

    Re: Use VBA to load a input window (table) in ie?

    The line that gives the error message: "Runtime error '438': object doesn't support this property or method"

    Please Login or Register  to view this content.

  12. #12
    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: Use VBA to load a input window (table) in ie?

    Hello max3732,

    This should fix the problem. I was referencing the buttons before the Form they were on was loaded.
    Please Login or Register  to view this content.

  13. #13
    Forum Contributor
    Join Date
    04-01-2010
    Location
    USA
    MS-Off Ver
    Office 2021
    Posts
    185

    Re: Use VBA to load a input window (table) in ie?

    I tried running it again and it gives an error at a different spot:

    Please Login or Register  to view this content.
    Is it getting past the first screen with the ad?

  14. #14
    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: Use VBA to load a input window (table) in ie?

    Hello max3732,

    It works on computer. I would check your settings and see if cookies are enabled or not. IE may be waiting for a response from you before it proceeds.

  15. #15
    Forum Contributor
    Join Date
    04-01-2010
    Location
    USA
    MS-Off Ver
    Office 2021
    Posts
    185

    Re: Use VBA to load a input window (table) in ie?

    It works if the main gamespot page is loaded. However, when you first log on to the site there is a full page ad that requires you to either wait for a few seconds or click on the "continue to gamespot link" on the website.

    I have ie deleting my history and clearing the cache after I close the browser so I see this every time I open a new browser. Is there a way to determine whether the ad or the main page has loaded in order to determine what action to take?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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