+ Reply to Thread
Results 1 to 13 of 13

How do I select already open IE win and save its web page source code to local *.txt file?

  1. #1
    Registered User
    Join Date
    08-25-2012
    Location
    Goiania
    MS-Off Ver
    Excel 2013 64 bits
    Posts
    10

    Question How do I select already open IE win and save its web page source code to local *.txt file?

    I need to grab some public data from a website, but the data in question is only accessible if the user clicks in an link that opens a new IE window with the desired data. Despite being newbie to Excel / VBA I managed to do a rudimentary code able to click on the link that opens the window with the desired data. Here is my code:

    Please Login or Register  to view this content.
    So far everything is working fine.

    Now I need a code to select the new opened window and save the source code of it's webpage to a local *.txt file. I have tried some examples, including queries to the first page that shows the desired data too, but none worked. The only way I found to grab the data was saving the source code of the second web page to disk and parsing it.

    Can someone help me?

  2. #2
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: How do I select already open IE win and save its web page source code to local *.txt f

    There is a piece of code for this on here, a week or so ago, try searching the forum.
    Hope this helps

    Sometimes its best to start at the beginning and learn VBA & Excel.

    Please dont ask me to do your work for you, I learnt from Reading books, Recording, F1 and Google and like having all of this knowledge in my head for the next time i wish to do it, or wish to tweak it.
    Available for remote consultancy work PM me

  3. #3
    Registered User
    Join Date
    08-25-2012
    Location
    Goiania
    MS-Off Ver
    Excel 2013 64 bits
    Posts
    10

    Re: How do I select already open IE win and save its web page source code to local *.txt f

    Quote Originally Posted by nathansav View Post
    There is a piece of code for this on here, a week or so ago, try searching the forum.
    I tried it two times, but advanced search appears not working: header('HTTP/1.1 503 Service Temporarily Unavailable'); header('Status: 503 Service Temporarily Unavailable'); header('Retry-After: 17200'); // in seconds print "TEST123";

  4. #4
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: How do I select already open IE win and save its web page source code to local *.txt f

    This should do it

    Please Login or Register  to view this content.
    Regards
    Sean

    Please add to my reputation if you think i helped
    (click on the star below the post)
    Mark threads as "Solved" if you have your answer
    (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code:
    [code] Your code here [code]
    Please supply a workbook containing example Data:
    It makes its easier to answer your problem & saves time!

  5. #5
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: How do I select already open IE win and save its web page source code to local *.txt f

    This one will run through all ie.applications open

    Please Login or Register  to view this content.

  6. #6
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: How do I select already open IE win and save its web page source code to local *.txt f

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    08-25-2012
    Location
    Goiania
    MS-Off Ver
    Excel 2013 64 bits
    Posts
    10

    Re: How do I select already open IE win and save its web page source code to local *.txt f

    Quote Originally Posted by Sean Thomas View Post
    This should do it

    Please Login or Register  to view this content.

    This code worked with (.Count - 1)! But, instead navigate to "http://support.microsoft.com/kb/q176792/" I need to save the webpage source code to a *.txt file. Can You give me a bit more help with this? (I'm suffering of hepatic encephalopathy.) Thank You, Sean!

  8. #8
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: How do I select already open IE win and save its web page source code to local *.txt f


    To grab data is not necessary to save source codepage to a file …

  9. #9
    Registered User
    Join Date
    08-25-2012
    Location
    Goiania
    MS-Off Ver
    Excel 2013 64 bits
    Posts
    10

    Re: How do I select already open IE win and save its web page source code to local *.txt f

    Quote Originally Posted by Marc L View Post

    To grab data is not necessary to save source codepage to a file …
    I suppose You are right, Marc. Can You give me a simple example inserted in the code below? I asked about save web page code to file cause I feel more confortably parsing *.txt files saved to disk... (I am old and sick. Then, if possible, I want to do an task without spend much time learning new things...)

    This is our code until now:

    Please Login or Register  to view this content.

  10. #10
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: How do I select already open IE win and save its web page source code to local *.txt f

    can you give out the url? there might be an easier way to get the data without saving it as txt. As Marc indicated, if we know what you want to get from the site I have some code that will open a url, make any changes, press buttons and then get the data from the updated site. This might be easier if you give some more info as to what you are doing. PM me if it is confidential.

  11. #11
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: How do I select already open IE win and save its web page source code to local *.txt f


    Agree with Sean.

    'Cause structure is different from a webpage to another one, there are different ways to grab data.

    Exemple in this thread to grab a table by using the clipboard …

  12. #12
    Registered User
    Join Date
    08-25-2012
    Location
    Goiania
    MS-Off Ver
    Excel 2013 64 bits
    Posts
    10

    Re: How do I select already open IE win and save its web page source code to local *.txt f

    Quote Originally Posted by Sean Thomas View Post
    can you give out the url? there might be an easier way to get the data without saving it as txt. As Marc indicated, if we know what you want to get from the site I have some code that will open a url, make any changes, press buttons and then get the data from the updated site. This might be easier if you give some more info as to what you are doing. PM me if it is confidential.
    This is no longer necessary. I managed to save the web page code to disk with this code:

    Please Login or Register  to view this content.
    Thank you very much, Sean.

  13. #13
    Registered User
    Join Date
    08-25-2012
    Location
    Goiania
    MS-Off Ver
    Excel 2013 64 bits
    Posts
    10

    Re: How do I select already open IE win and save its web page source code to local *.txt f

    Quote Originally Posted by Marc L View Post

    Agree with Sean.

    'Cause structure is different from a webpage to another one, there are different ways to grab data.

    Exemple in this thread to grab a table by using the clipboard …
    Read my response to Sean, Marc. Thank you very much!

+ 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. Replies: 1
    Last Post: 12-26-2013, 04:55 AM
  2. Remote data source for local excel file
    By dymention2 in forum Excel General
    Replies: 0
    Last Post: 04-29-2012, 09:45 AM
  3. Macro to open URL then save page as a text file
    By jasocke2 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-11-2009, 10:06 AM
  4. VBA to save a web page to local disk
    By Ron in forum Excel General
    Replies: 0
    Last Post: 04-26-2006, 12:40 PM
  5. How to write a micro to download file at a URL save the file at the local PC
    By www.microsoft.com in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-08-2006, 10:21 PM

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