Solved

Copy displayed web page text with vba

Posted on 2014-12-03
7
2,844 Views
Last Modified: 2014-12-07
I need to copy the displayed text from a web page to a string.  The text is generated by the web page and not available directly from the source.  I need to obtain with vba code the same result I would get from manually selecting the entire web page text, copying it to clipboard, then pasting it into notepad.  I am using MS Office 2014 (Access).
0
Comment
Question by:riverguy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 34

Expert Comment

by:ste5an
ID: 40480828
You need to automate your web browser to copy the text from the DOM.
0
 

Author Comment

by:riverguy
ID: 40482209
ste5an, thanks for the answer.  I'm not familiar with using DOM.  Would you mind giving me an example.  The information I want is not available in the source HTML, but is obtained by embedded javascript within it.   The web page is a movie schedule at http://www.fandango.com/theaterpage-prn.aspx?tid=AAWVN&date=12%2f4%2f2014 where the date elements are included in the URL.  I want to copy the output string.
0
 
LVL 46

Assisted Solution

by:aikimark
aikimark earned 150 total points
ID: 40482681
You can get the HTML quite easily with the MSXML2.XMLHTTP object.  What are you doing with the "text" on the page?
0
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 

Author Comment

by:riverguy
ID: 40485187
I was mistaken, the text I'm looking for is available in the source text of the web page and I can get it as you suggested with an MSXML2 object in .responseText in the HTML format.  I'll have to ferret out pulling the data from the HTML.  I'm wondering if there is an object property that represents the output text, the same text one would get with selecting and copying to the clipboard all the contents of the web page, or will it have to be parsed out node by node?  I can probably go it from here.  Thanks for the help.  I'm open to any suggestions for extracting the output text.
0
 
LVL 17

Accepted Solution

by:
vb_elmar earned 350 total points
ID: 40485199
To get the entire innertext of a web page use the "Microsoft HTML Object Library"
'add a reference to Microsoft WinHttp Services 5.0
'add a reference to Microsoft HTML Object Library

Private Sub CommandButton1_Click()
    Dim Req As New WinHttpRequest
    Dim RT As String, HasData As Boolean
    Dim Doc As New HTMLDocument
    
    Req.Open "GET", "http://en.wikipedia.org/wiki/Rashmi_Gautam"
    Req.Send
    RT = Req.ResponseText

    Set Doc = New HTMLDocument
    Doc.Clear
    CallByName Doc, "Write", VbMethod, RT

    MsgBox Doc.Body.innertext
End Sub

Open in new window

0
 

Author Comment

by:riverguy
ID: 40485202
Thanks, that did it.  My mistake was in not recognizing that the information was in the HTML.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
Suggested Courses

632 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question