上边是从 Web Server 上取!
这里是从本地 IE 窗口里取:
'引用 Microsoft Internet Controls
Option Explicit
Private Sub Command1_Click()
'从本地 IE 窗口中,取得标题栏中含有 "中" 字符的第一个 IE 窗口的 HTML 源!
Text1.Text = GetSourceOfHTMLPage("*中*")
End Sub
'该函数是用来从本地 IE 窗口中,取得标题栏中含有 TitlePattern 字符的的第一个 IE 窗口的 HTML 源!
Public Function GetSourceOfHTMLPage(TitlePattern As String) As String
Dim x As New SHDocVw.ShellWindows
Dim i As Long
Dim j As Long
For i = 0 To x.Count - 1
If VBA.TypeName(x.Item(i).Document) = "HTMLDocument" Then
If x.Item(i).Document.Title Like TitlePattern Then
'Debug.Print x.Item(i).Document.documentElement.outerhtml
GetSourceOfHTMLPage = x.Item(i).Document.documentElement.outerhtml
Exit For
End If
End If
Next i
End Function