+ Reply to Thread
Results 1 to 18 of 18

Import data from a web page

  1. #1
    Registered User
    Join Date
    08-18-2011
    Location
    Denver Colorado
    MS-Off Ver
    Excel 2007
    Posts
    65

    Import data from a web page

    I have no experience pulling data from a web page to import to excel. I've borrowed some code I found here, but am stuck on how to proceed once I reach the website. I've attached the spreadsheet, as well as a word document showing my desires. Any and all help will be HUGELY appreciated!

    1. sub Import() needs to make elections before running report. Using the link, copy and paste the table to Summary.

    2. Using the links in the table, prompt the user for a location to save each .CSV with a unique name, then sub combinespreadsheets() populates Master.

    3. Would like a worksheet change event on Aging inventory D2 to filter Master by column L including blanks, hide the columns in sub CreateAgingList(), then paste the visible cells back to Aging Inventory
    Attached Files Attached Files
    Last edited by Hoosaskin; 12-13-2011 at 10:19 AM. Reason: added ZIP file

  2. #2
    Forum Expert Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    locked in the cage
    MS-Off Ver
    All the ones my homepage shows
    Posts
    3,161

    Re: Import data from a web page

    One of these links may help you:
    http://www.thecodecage.com/forumz/mi...vbulletin.html
    http://www.thecodecage.com/forumz/mi...lications.html
    http://www.thecodecage.com/forumz/mi...nto-excel.html
    Not all forums are the same - seek and you shall find

  3. #3
    Registered User
    Join Date
    08-18-2011
    Location
    Denver Colorado
    MS-Off Ver
    Excel 2007
    Posts
    65

    Re: Import data from a web page

    Didn't really help. Can anyone help me out?

  4. #4
    Forum Expert Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    locked in the cage
    MS-Off Ver
    All the ones my homepage shows
    Posts
    3,161

    Re: Import data from a web page

    Reading the very first part of your question "am stuck on how to proceed once I reach the website" those links i gave you are to code that actually gets data from websites, one of them shows you how to fill in name boxes..etc, so if you look carefully at the code i'm sure it would help. Also there aren't any attachments in your first post

  5. #5
    Registered User
    Join Date
    08-18-2011
    Location
    Denver Colorado
    MS-Off Ver
    Excel 2007
    Posts
    65

    Re: Import data from a web page

    Two files contained within the ZIP file.

  6. #6
    Registered User
    Join Date
    08-18-2011
    Location
    Denver Colorado
    MS-Off Ver
    Excel 2007
    Posts
    65

    Re: Import data from a web page

    I could really use some help. My attempt at a web query was a bust.

  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: Import data from a web page

    Hello Hoosaskin,

    Because the URL is an intranet and internet address, we can not access the site or web page. To help you, you will need to save the page source as a text file and post it (IE menu: View > Source).
    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!)

  8. #8
    Registered User
    Join Date
    08-18-2011
    Location
    Denver Colorado
    MS-Off Ver
    Excel 2007
    Posts
    65

    Re: Import data from a web page

    Here 3 files showing what the pages looks like, as well as their source code.
    Run report is first, then get to table and inventory
    Attached Files Attached Files
    Last edited by Hoosaskin; 01-09-2012 at 11:01 AM.

  9. #9
    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: Import data from a web page

    Hello Hoosaskin,

    Thank you for posting all that information. That is exactly what I was looking for. I am currently writing the code to automate copying the data to the worksheet. Just wanted to let you know what is happening.

  10. #10
    Registered User
    Join Date
    08-18-2011
    Location
    Denver Colorado
    MS-Off Ver
    Excel 2007
    Posts
    65

    Re: Import data from a web page

    Thank you for your time!

  11. #11
    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: Import data from a web page

    Hello Hoosaskin,

    I need to know if the sample HTML files are exact copies from the web pages. I have most of the code written but Internet Explorer fails to retrieve the files from my hard drive. I can open the files fine with FireFox and Chrome. If the files are the exact copies then perhaps once you are logged on then Internet Explorer will work. This is a something I have never come across before.

  12. #12
    Registered User
    Join Date
    08-18-2011
    Location
    Denver Colorado
    MS-Off Ver
    Excel 2007
    Posts
    65

    Re: Import data from a web page

    Hi Leith,

    The source codes I sent are complete for each page. I did toy with removing some of the blank spaces between the lines, to make the files smaller, but didn't change anything other than the margins in the documents.

    Sean

  13. #13
    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: Import data from a web page

    Hello Sean,

    It is so nice to Sean spelled as it is in the Gaelic. I feel confident that once you are logged on Internet Explorer the macro will work correctly. I do have another question. When the report is run and I am assuming you want the entire process automated, the choices listed in the Word file will be the same for all users, yes?

  14. #14
    Registered User
    Join Date
    08-18-2011
    Location
    Denver Colorado
    MS-Off Ver
    Excel 2007
    Posts
    65

    Re: Import data from a web page

    Is there any other way to spell Sean?!?!? I think not!

    When making the request to run the report, I'd like the user to be prompted for the Station ID only. All other choices should be as marked below.

    1. View data as of: accept default
    2. Show report for: change National to Select Stations
    3. Prompt for station number
    4. Use Status: accept default
    5. Equipment type: change to All
    6. Category Stock Number: accept default
    7. Run report

    I'm not sure what affect selecting other than 554 as station ID (for me) will have on the source code of the subsequent web pages. Would you like to see the code if I use another choice?

    Sean

  15. #15
    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: Import data from a web page

    Hello Sean,

    Thanks for the clarification. If you can post the page for comparison that would be great. It will certainly head off any problems.

  16. #16
    Registered User
    Join Date
    08-18-2011
    Location
    Denver Colorado
    MS-Off Ver
    Excel 2007
    Posts
    65

    Re: Import data from a web page

    Here you go Leith. The second screen is run with station 436. The third is Statistics Table. Thank you again for working on this.

    Sean
    Attached Files Attached Files

  17. #17
    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: Import data from a web page

    Hello Sean,

    Thanks for the additional files. It was a big help in checking the code. The attached workbook has one button on the "Instructions" sheet called "Run Report". This macro calls up a UserForm I added that allows you to type in your user name and password. The password appears as asterisks in the text box. The button labeled "Log On" kicks off all the other macros for selecting the report, importing the table, and saving the CSV files.

    The only modification that needs to be made is to the "Log On" code. I do not know what the names of the user name input, password input, and submit button are. Perhaps you can add the needed names. The code appears below.
    Please Login or Register  to view this content.
    Try out the attached workbook and let me know of any problems that occur or changes you would to make.
    Attached Files Attached Files

  18. #18
    Registered User
    Join Date
    08-18-2011
    Location
    Denver Colorado
    MS-Off Ver
    Excel 2007
    Posts
    65

    Re: Import data from a web page

    Hello Leith,

    Firstly, thank your for all your time with this! Nothing I tried would work. I just tried running the macro, and after clicking the log on button (there is no user name or password required, just a va.gov user), I got a run time error 91: object variable or with block variable not set for this line of code:
    Please Login or Register  to view this content.
    Since user name and password aren't necessary, I commented them out. It ran all the way through. One issue is the SUB combinespreadsheets() asks the user to indicate where the .CSV files, from the third screen, are saved. Could you put in an input box for the user to specify this location?

    Another is the imported table for the summary tab. The macro grabbed the first page after creating the report. I need it to open the link that created from running the report and import the subsequent table.

    And somewhere along the line, since everything runs from the instruction tab, the instructions get cleared, auto-filter and freeze frame are applied. I tried stepping through the macros as they run, but once they've started I can't change from the Instructions tab.

    Thank you again for all your time!


    Sean

    10:22- Now I'm getting a run time error 91 object variable or with block variable not set at this line (with user id/password commented) of IMPORT TABLE:
    Please Login or Register  to view this content.
    Should this need another ie.app busy or ie.app readystate statement while the site is conducting the query?
    smb
    Last edited by Hoosaskin; 01-23-2012 at 01:28 PM. Reason: New run time error

+ 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