Solved

How to Get HTML code of a IE page

Posted on 2006-07-20
1
221 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
[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
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

Technology Partners: 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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
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…
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…
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…

734 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