Pub.bas
资源名称:IE_VB.rar [点击查看]
上传用户:davilee3
上传日期:2015-04-22
资源大小:986k
文件大小:2k
源码类别:
浏览器
开发平台:
Visual Basic
- Attribute VB_Name = "mPub"
- '---------------------------------------------------------------------------------------
- ' Module : mPub
- ' DateTime : 2005-8-15 16:58
- ' Author : Lingll
- ' Purpose :
- '---------------------------------------------------------------------------------------
- Option Explicit
- '枚举页面中所有的frame
- Public Sub EnumFrames(ByVal wb As SHDocVw.WebBrowser, wbs As Collection)
- Dim pContainer As olelib.IOleContainer
- Dim pEnumerator As olelib.IEnumUnknown
- Dim pUnk As olelib.IUnknown
- Dim pBrowser As SHDocVw.WebBrowser
- Set pContainer = wb.Document
- ' Get an enumerator for the frames
- If pContainer.EnumObjects(OLECONTF_EMBEDDINGS, pEnumerator) = 0 Then
- Set pContainer = Nothing
- ' Enumerate and refresh all the frames
- Do While pEnumerator.Next(1, pUnk) = 0
- On Error Resume Next
- ' Clear errors
- Err.Clear
- ' Get the IWebBrowser2 interface
- Set pBrowser = pUnk
- If Err.Number = 0 Then
- 'Debug.Print "Frame: " & pBrowser.LocationURL
- wbs.Add pBrowser
- Call EnumFrames(pBrowser, wbs)
- End If
- Loop
- Set pEnumerator = Nothing
- End If
- End Sub
- Public Function GetHtml(vWeb As SHDocVw.WebBrowser, Optional vSelWeb As SHDocVw.WebBrowser) As String
- On Error Resume Next
- Dim tCol As New Collection
- Dim tWeb As SHDocVw.WebBrowser
- Dim tStr$, tstr2$
- tCol.Add vWeb
- Call EnumFrames(vWeb, tCol)
- For Each tWeb In tCol
- tStr = vbNullString
- Err.Clear
- tStr = tWeb.Document.Selection.createRange.htmltext
- If Err.Number = 0 Or Err.Number = INET_E_DEFAULT_ACTION Then
- If LenB(tStr) > 0 Then
- Set vSelWeb = tWeb
- Exit For
- End If
- End If
- Next tWeb
- GetHtml = tStr
- End Function