+ Reply to Thread
Results 1 to 9 of 9

Use VBA to control Internet Explorer

  1. #1
    Forum Contributor
    Join Date
    05-29-2014
    MS-Off Ver
    Office 2013
    Posts
    115

    Use VBA to control Internet Explorer

    Hi everybody!

    I have a question regarding VBA. I wanted to know, how I can learn to control internet explore using VBA from excel.

    I would really appreciate if you give me a direction from where to start.

    Thanks.

  2. #2
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Use VBA to control Internet Explorer

    Hi Verbamore,

    Here is a good place to start. http://www.codeforexcelandoutlook.co...rnet-explorer/

    One of the problems is that most web sites use JavaScript which makes things a lot more difficult for us mere mortals.

    Lewis

  3. #3
    Forum Contributor
    Join Date
    05-29-2014
    MS-Off Ver
    Office 2013
    Posts
    115

    Re: Use VBA to control Internet Explorer

    Quote Originally Posted by LJMetzger View Post
    Hi Verbamore,

    Here is a good place to start. http://www.codeforexcelandoutlook.co...rnet-explorer/

    One of the problems is that most web sites use JavaScript which makes things a lot more difficult for us mere mortals.

    Lewis
    Thank you LJMetzger for your response.
    I am trying to control two wepages opened in two tabs but it looks like impossible to me.
    I am trying to copy information from one and paste them to the other.
    I would really appreciate if you give me an orientation.

  4. #4
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Use VBA to control Internet Explorer

    Here is some very simple code to get you started. I suggest you run it by single stepping through the debugger. The information output by 'DiagnosticDebugDotPrint()' contains information that you may be able to extract/paste from/to Internet Explorer. This only works in 32 bit Excel (apiShowWindow declaration must be updated to run in 64 bit Excel).

    Substitute the URL of your choice, experiment, and looking at the Debugger locals window may help. 'Debug.Assert False' stops the debugger so you can examine items while everything is stopped. I only have very basic IE Automation skills, and everything I learned about IE automation has been very tedious and painful.

    Lewis

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    05-29-2014
    MS-Off Ver
    Office 2013
    Posts
    115

    Re: Use VBA to control Internet Explorer

    Quote Originally Posted by LJMetzger View Post
    Here is some very simple code to get you started. I suggest you run it by single stepping through the debugger. The information output by 'DiagnosticDebugDotPrint()' contains information that you may be able to extract/paste from/to Internet Explorer. This only works in 32 bit Excel (apiShowWindow declaration must be updated to run in 64 bit Excel).

    Substitute the URL of your choice, experiment, and looking at the Debugger locals window may help. 'Debug.Assert False' stops the debugger so you can examine items while everything is stopped. I only have very basic IE Automation skills, and everything I learned about IE automation has been very tedious and painful.

    Lewis

    Please Login or Register  to view this content.
    Hi LJMetzger
    First of all I would like to say thank you for your huge help on this.
    I just tried(was a long time since the last post, I was on vacation) and to be honest I didn’t understand to much. My knowledge on vba are very superficial.
    So I was thinking to tell you some information for my project and maybe you have an idea to where to put my finite efforts.
    What I’m trying to do is to create a UserForm. This should catch all my e-mails based on some conditions( I thinking to uses some filter). After that the code is gonna take the information from there and is gonna open IE. In IE the code is going to do some copy and paste( for this part was the purpose of the thread here).
    My idea is to do all of this in backstage( not sure if this is possible) ,so I can do something else in meantime.
    I know some stuff in vba I can’t say that I am a beginner nether an expert.
    Based on above do you have any suggestion?
    I am thinking perhaps vba is not the best solution to resolve this problem.
    I would really appreciate if you could give me an idea about this.

  6. #6
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Use VBA to control Internet Explorer

    This should catch all my e-mails based on some conditions( I thinking to uses some filter). After that the code is gonna take the information from there and is gonna open IE. In IE the code is going to do some copy and paste( for this part was the purpose of the thread here).
    I like the idea of filtering the e-mails. I don't think IE is a good tool to use. IE automation is very difficult and extremely time consuming to develop and debug the code. If you can import the data into Excel, Excel VBA is powerful enough to do almost anything with the data, and very efficient in terms of develop/debug time.

    My idea is to do all of this in backstage( not sure if this is possible) ,so I can do something else in meantime.
    If you open up a separate instance of Excel, it can run and execute a macro while you do other things on the computer.

    I hope this helps.

    Lewis

  7. #7
    Forum Contributor
    Join Date
    05-29-2014
    MS-Off Ver
    Office 2013
    Posts
    115

    Re: Use VBA to control Internet Explorer

    Quote Originally Posted by LJMetzger View Post
    I like the idea of filtering the e-mails. I don't think IE is a good tool to use. IE automation is very difficult and extremely time consuming to develop and debug the code. If you can import the data into Excel, Excel VBA is powerful enough to do almost anything with the data, and very efficient in terms of develop/debug time.



    If you open up a separate instance of Excel, it can run and execute a macro while you do other things on the computer.

    I hope this helps.

    Lewis
    Thank you Lewis.
    I work using an online system. This system generate data based on what I request(using conditions).
    For exp. let's assume that i have to add a name in one contract. what do I have to do is: run a report before I do changes, do changes( add the name) and run a report after changes. Everything is up to date and I don't know if there is any option to do this in excel.

  8. #8
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Use VBA to control Internet Explorer

    Now that I see what you want to do, it's possible, but it will probably require a lot of programming skill. It is way beyond my capabilities.

    Having said that, here is another more advanced working example code. This attempts to log in to a web site (and fails - I don't have an account on the web site). It enters log in information, and attempts to log in. The debugger output will show you data after various steps along the way. Once past the log in Screen, most web sites switch to Javascript. You have now tapped almost my entire Internet Automation knowledge.

    Here are a few debugger tips.
    a. Press 'F8' to single step (goes into subroutines and functions).
    b. Press SHIFT 'F8' to single step OVER subroutines and functions.
    c. Press CTRL 'F8' to stop at the line where the cursor is.
    d. 'Left Click' the margin to the left of a line to set (or clear) a BREAKPOINT.
    e. Press CTRL 'G' to open the IMMEDIATE WINDOW. 'debug.print' statements send their
    output to the IMMEDIATE WINDOW.
    f. Select View > Locals to see all variables while debugging.
    g. To automatically set a BREAKPOINT at a certain location put in the line:
    'Debug.Assert False'
    h. To conditionally set a BREAKPOINT at a certain location put in lines similar to:
    if i >= 20 and xTV20 > 99.56 then
    Debug.Assert False
    endif
    i. A variable value will be displayed by putting the cursor over the variable name.

    Lewis

    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    05-29-2014
    MS-Off Ver
    Office 2013
    Posts
    115

    Re: Use VBA to control Internet Explorer

    Quote Originally Posted by LJMetzger View Post
    Now that I see what you want to do, it's possible, but it will probably require a lot of programming skill. It is way beyond my capabilities.

    Having said that, here is another more advanced working example code. This attempts to log in to a web site (and fails - I don't have an account on the web site). It enters log in information, and attempts to log in. The debugger output will show you data after various steps along the way. Once past the log in Screen, most web sites switch to Javascript. You have now tapped almost my entire Internet Automation knowledge.

    Here are a few debugger tips.
    a. Press 'F8' to single step (goes into subroutines and functions).
    b. Press SHIFT 'F8' to single step OVER subroutines and functions.
    c. Press CTRL 'F8' to stop at the line where the cursor is.
    d. 'Left Click' the margin to the left of a line to set (or clear) a BREAKPOINT.
    e. Press CTRL 'G' to open the IMMEDIATE WINDOW. 'debug.print' statements send their
    output to the IMMEDIATE WINDOW.
    f. Select View > Locals to see all variables while debugging.
    g. To automatically set a BREAKPOINT at a certain location put in the line:
    'Debug.Assert False'
    h. To conditionally set a BREAKPOINT at a certain location put in lines similar to:
    if i >= 20 and xTV20 > 99.56 then
    Debug.Assert False
    endif
    i. A variable value will be displayed by putting the cursor over the variable name.

    Lewis

    Please Login or Register  to view this content.
    Thanks man for your help, but I can't understand I have just some basic knowledge in vba.

    I have already resolve the problem of doing log in and open two different tabs,[I used clng(2028)] ( this because as i explained above, i need to run reports, so one tab is for the contract that i have to changes and the other is the tab that I opened for the report section. Before doing changes i have to run a report. What i do is press f12 and find the element( in my case is contract name) by clicking. After i have found the contract name, I have to copy and paste to the other tab( the tab that i use to run report) no clue how to do this. So copy element text form one tab to another.

+ 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. internet explorer control click
    By tomro1 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-14-2014, 12:11 PM
  2. VBA to control Internet Explorer to open files
    By rugbykorn in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-28-2013, 04:15 PM
  3. Can Excel control Internet Explorer using VBA?
    By simpleonline1234 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-01-2012, 10:39 PM
  4. Using VBA to control Internet Explorer Error Problems
    By John Richter in forum Excel General
    Replies: 0
    Last Post: 02-20-2012, 05:09 PM
  5. Using Macros for Internet Explorer Control
    By PaulAS in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-08-2010, 03:58 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