Web Objects

Posted on 2003-03-04
Medium Priority
Last Modified: 2010-05-01
I have a vbscript that i'm currently using to copy the contents automatically from ie into notepad using SendKeys "^a^c" and then "^v".

I'd like to write a similar program using Visual Basic, however seeing as it's a more versatile language, there must be a better way to copy the textual content of the webobject.

Question by:Lothian
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

Expert Comment

ID: 8064319
You can use the Webbrowser object on a form to display the chosen web page. Call the Navigate function of the Webbrowser control passing it the URL you wish to view.

When the page has finished downloading (you can wait for the Document Complete event to fire) you can access any of the objects on the webpage using the DOM.

For example if the object is an INPUT element (a text box) and it has an ID of 'Password' which is on a form called 'Login' you can access the contents of the text box in the document the same way you would if you were writting a script than ran in the page itself. 'Webbrowser1.Document.Login.Password' would reference the INPUT element. All you would need to do then is copy its text (Value) into a string.
LVL 14

Accepted Solution

aelatik earned 200 total points
ID: 8064542
Here, this will fetch the source between the body tags ( you have to search for what you want inside the result of GetHTMLCode.

Private Sub Form_Load()
GetHTMLCode ("http://www.google.com")
End Sub

Public Function GetHTMLCode(URL As String)
  Dim IE
  Set IE = CreateObject("InternetExplorer.Application")
      IE.Navigate URL
      While IE.Busy
          GetHTMLCode = IE.Document.body.innerHTML
          'Replace above line with below if you want the entire page instead of the body tags
          'GetHTMLCode = IE.Document.documentelement.innerHTML
  MsgBox GetHTMLCode
End Function

Author Comment

ID: 8064772
What I actually need to do is access content that is generated to a table. So essentially, i need a text capture of the contents of that page for later parsing.

Thanks for the input though.

Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month8 days, 20 hours left to enroll

764 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