Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to Get HTML code of a IE page

Posted on 2006-07-20
1
Medium Priority
?
225 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 1000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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

916 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