+ Reply to Thread
Results 1 to 10 of 10

Navigating a web browser (Firefox, IE or google chrome) through VBA

  1. #1
    Registered User
    Join Date
    02-02-2012
    Location
    Denver, Colorado
    MS-Off Ver
    Excel 2010
    Posts
    35

    Navigating a web browser (Firefox, IE or google chrome) through VBA

    Hi,

    I was wondering if it is possible to navigate a web browser such as Firefox, IE or Google Chrome through VBA. I would like to get user information from a user form in VBA and then navigate through several web pages to achieve the final goal of pulling real time information from the web into excel.

  2. #2
    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: Navigating a web browser (Firefox, IE or google chrome) through VBA

    Hello Jimmy Smith,

    You can navigate most easily with VBA using Internet Explorer. You will need to provide much more detail about what you want do before any usable solution can be created.
    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!)

  3. #3
    Registered User
    Join Date
    02-02-2012
    Location
    Denver, Colorado
    MS-Off Ver
    Excel 2010
    Posts
    35

    Re: Navigating a web browser (Firefox, IE or google chrome) through VBA

    Hi Leith,

    I am still in the beginning phases of coding so I do not have very much to show you. What I have gotten is:
    Please Login or Register  to view this content.

    I know that I can look at the html code of the page to pick out the specific items that I would like to modify but since I have never used html before I really don't know where to start. My end goal would be to have a user form that would take the information from the user and input this into the web page. I'm sorry I can't really provide more information on this but any help or advice in the right direction will help a lot!


    Thanks

  4. #4
    Registered User
    Join Date
    02-02-2012
    Location
    Denver, Colorado
    MS-Off Ver
    Excel 2010
    Posts
    35

    Re: Navigating a web browser (Firefox, IE or google chrome) through VBA

    Another question, if i know the name of an object in IE, how do I click it or change the value of it?

  5. #5
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Navigating a web browser (Firefox, IE or google chrome) through VBA

    Hi,

    I'm no expert on the matter, but I have found this webpage to be helpful.
    Please consider:

    Thanking those who helped you. Click the star icon in the lower left part of the contributor's post and add Reputation.
    Cleaning up when you're done. Mark your thread [SOLVED] if you received your answer.

  6. #6
    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: Navigating a web browser (Firefox, IE or google chrome) through VBA

    Hello JimmySmith,

    I would need to know what you are looking for on the page.

    @Abousetta - Looks like a good reference. Thanks for posting that.

  7. #7
    Registered User
    Join Date
    02-02-2012
    Location
    Denver, Colorado
    MS-Off Ver
    Excel 2010
    Posts
    35

    Re: Navigating a web browser (Firefox, IE or google chrome) through VBA

    So on http://www.imf.org/external/np/fin/e...yDataBase.aspx
    I would like to be able to click on "Representative Rates" under the "Select Exchange Rate Type" heading and be able to change the "Select Date" area to either "Period" or "Date Range" (If date range was to be selected, I would also need to be able to specify the dates) and I would like to do this all through VBA. I looked through the source coding of the page and I think that the "Representative Rates" object name is _lblExchangeName"> however, I have no experience in html and could be totally wrong.

    I want to thank you guys again for helping me with this issue. And I will continue to look through the link posted by Abousetta

  8. #8
    Registered User
    Join Date
    02-02-2012
    Location
    Denver, Colorado
    MS-Off Ver
    Excel 2010
    Posts
    35

    Re: Navigating a web browser (Firefox, IE or google chrome) through VBA

    Here is a piece of the code that I have been working on:
    Please Login or Register  to view this content.
    I commented my newest part of the code but I still haven't been able to get it to work. I'm a little confused on how getElementsByName works and how VBA communicates with IE. (I was playing around with an If..Then Statement and a For Each loop)

  9. #9
    Valued Forum Contributor
    Join Date
    05-21-2009
    Location
    Great Britain
    MS-Off Ver
    Excel 2003
    Posts
    550

    Re: Navigating a web browser (Firefox, IE or google chrome) through VBA

    You should be able to retrieve the data without IE automation.

    Look at the URL in the browser address bar on the step 4 web page, for example:

    http://www.imf.org/external/np/fin/e...nding&DT=Blank

    this contains all the settings chosen by manually navigating through steps 1 to 3. All you have to do in VBA is construct this URL according to the chosen options and dates, etc. I'm guessing that the date range values are the number of milliseconds (or similar) since a base date, which you will need to determine in order to calculate the date values.

    If you open the above URL in Excel (File - Open - the URL) it retrieves a web page but without any data. All is not lost though. Copy the Excel download link on the step 4 web page. This is always:

    http://www.imf.org/external/np/fin/e...spx?Type=Excel

    If you add the query parameters from the first URL to the Excel URL you get:

    http://www.imf.org/external/np/fin/e...nding&DT=Blank

    Open this URL in Excel (File - Open - paste the URL as the file name to be opened). Go through the Text Import Wizard (the data is tab-delimited) and Excel retrieves the data in a separate workbook. So to get the data in VBA, construct the Excel URL with query parameters according to the required options and dates

  10. #10
    Valued Forum Contributor
    Join Date
    05-21-2009
    Location
    Great Britain
    MS-Off Ver
    Excel 2003
    Posts
    550

    Re: Navigating a web browser (Firefox, IE or google chrome) through VBA

    Quote Originally Posted by Chippy View Post
    You should be able to retrieve the data without IE automation.

    If you add the query parameters from the first URL to the Excel URL you get:

    http://www.imf.org/external/np/fin/e...nding&DT=Blank

    Open this URL in Excel (File - Open - paste the URL as the file name to be opened). Go through the Text Import Wizard (the data is tab-delimited) and Excel retrieves the data in a separate workbook.
    It looks like I was wrong about this, probably due to requesting the same URL with IE, which established session variables with the web server, because with the following code the Step 1 web page is retrieved without any of the data.
    Please Login or Register  to view this content.
    Therefore I now think you will need to use IE automation to retrieve the data.

+ 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