Solved

How to Get HTML code of a IE page

Posted on 2006-07-20
1
217 Views
Last Modified: 2012-06-27
Hello Experts,

Using Visual how to get the Html contents of IE page. I am using this code

    Wb1.ExecWB OLECMDID_SELECTALL, OLECMDEXECOPT_DODEFAULT
    ' copy the text to Clipboard
    Wb1.ExecWB OLECMDID_COPY, OLECMDEXECOPT_DODEFAULT
    ' clear the selection
    Wb1.ExecWB OLECMDID_CLEARSELECTION, OLECMDEXECOPT_DONTPROMPTUSER
   
    'For Loopver = 1 To 100
    'sleep (10)
   ' Next
    Value1 = Clipboard.GetText(1)

but it is giving me only the things displayed on the page but i want the html code of it as i want to copy all the href contents.

How can i do this.

Thanks

vikas
0
Comment
Question by:vikas_maderna
1 Comment
 
LVL 20

Accepted Solution

by:
hes earned 250 total points
Comment Utility
Try this

'Add a reference to Microsoft Internet Controls

Option Explicit
Dim WithEvents Web1 As InternetExplorer
Dim TargetUrl As String
Dim blnComp As Boolean
Dim strHtml As String

' In your Code
Set Web1 = New InternetExplorer
Web1.Visible = True
TargetUrl = "http://www.experts-exchange.com ' Change to yout url
Web1.Navigate TargetUrl
blnComp = False

Do While blnComp = False
  DoEvents
Loop
strHtml = Web1.Document.body.innerHTML 'strHtml now contains the HTML of the page

Private Sub Web1_DocumentComplete(ByVal pDisp As Object, url As Variant)
 If url = TargetUrl Then
   blnComp = True
  End If
End Sub
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now