+ Reply to Thread
Results 1 to 7 of 7

Paste web page into workbook

  1. #1
    Registered User
    Join Date
    07-08-2009
    Location
    Gloucestershire, England
    MS-Off Ver
    Excel 2007
    Posts
    29

    Paste web page into workbook

    Hi, I have some code that opens a web page and enters two input boxes then submits the entries and a value is returned to the web page. I wanted to return the value to a work sheet but my knowledge is limited so I thought I'd copy and paste the web page into a worksheet instead but it doesn't appear to work. Nothing is pasted. Any help would be greatly appreciated. Thanks in advance.
    Attached Files Attached Files
    Last edited by skyblues; 08-22-2011 at 06:24 AM.

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Paste web page into workbook

    Try using

    Please Login or Register  to view this content.
    to generate an array of indvidual lines from the HTML which you can then pick from to get the desired value.
    Martin

  3. #3
    Registered User
    Join Date
    07-08-2009
    Location
    Gloucestershire, England
    MS-Off Ver
    Excel 2007
    Posts
    29

    Re: Paste web page into workbook

    Thanks for the reply mrice. I'm still struggling with this. I've updated the original attached file. The data that is being pasted doesn't seem to be from the current web page it seems to data from when the input boxes have been filled in and not submitted. On the excel sheet you can see lines 28 and 31 have the values filled in. If you look at the page source of the IE window that is open these values aren't filled and the result "Predicted TI is 13.331352260039" is shown in the source but not the data pasted in Excel.

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Paste web page into workbook

    Hello skyblues,

    Working with Internet Explorer through VBA is a bit tricky. Since Internet Explorer is started asynchronously from VBA, the VBA code runs at its own pace. The trick is to synchronize the VBA code execution with what Internet Explorer is doing. The way to do this is by using a Class Module with events.

    The attached workbook uses "A2" and "B2" as the ASI inputs. "C2" is where the calculated web page result is returned. There is a button to run the macro after you input the values.

    EDIT: Added error handler


    Module1 Macro Code
    Please Login or Register  to view this content.

    Class Module (IE_Class) Code
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by Leith Ross; 08-21-2011 at 07:11 PM. Reason: Added error handler to macro in Module1
    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!)

  5. #5
    Registered User
    Join Date
    07-08-2009
    Location
    Gloucestershire, England
    MS-Off Ver
    Excel 2007
    Posts
    29

    Re: Paste web page into workbook

    Hi Leith,

    Thank you very much for solving this and giving me the code I can't thank you enough as I've spent countless hours on trying to solve this with searches.

    The help given on this site always surprises me the people who contribute are so knowledgeable and helpful. Thank you again and sorry from straying off the topic.

  6. #6
    Registered User
    Join Date
    07-08-2009
    Location
    Gloucestershire, England
    MS-Off Ver
    Excel 2007
    Posts
    29

    Re: Paste web page into workbook

    Hi Leith,

    Could I ask for your help again? I'm trying to put a loop that looks up how many cells are populated in column A and then loop that many times. When I put a loop in I receive the following error: Run Time Error '70' Permission Denied.
    Thanks once again

  7. #7
    Registered User
    Join Date
    07-08-2009
    Location
    Gloucestershire, England
    MS-Off Ver
    Excel 2007
    Posts
    29

    Re: Paste web page into workbook

    Apologies I've just looked at my code again and I have made some errors. All working fine now. Thanks

+ 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