Solved

How to Get HTML code of a IE page

Posted on 2006-07-20
1
218 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
ID: 17149158
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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…

932 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

12 Experts available now in Live!

Get 1:1 Help Now