'------------------------------------------------
' »·¾³×¼±¸£º
' 1.ΪÔËÐб¾³ÌÐò£¬Ó¦ÔÚ¡°²Ëµ¥->¹¤³Ì->²¿¼þ¡±ÖÐÌí¼Ó¡°Microsoft Internet Controls¡±
' 2.²¢ÔÚ¡°²Ëµ¥->¹¤³Ì->ÒýÓá±ÖÐÌí¼Ó¡°Microsoft HTML Object Library¡±ºÍ¡°Edanmo's OLE interfaces & functions v1.4¡±
' 3.ÇëÏȽ¨Á¢Îļþ"d:\1.html"£¬ÄÚÈÝΪ£º<iframe application="yes" width=700 height=600 src="http://www.baidu.com" mce_src="http://www.baidu.com"></iframe>
' 4.Edanmo 's OLE interfaces & functions v1.4ÔÚÓÐЩ»úÆ÷¿ÉÄÜûÓУ¬¿ÉÒÔµ½ÕâÀïÏÂÔØ£ºhttp://download.csdn.net/source/2652292
'
' Author : sysdzw
' E-mail : sysdzw@163.com
' Bolg : http://hi.baidu.com/sysdzw
' QQ : 171977759
' Date : 2010-4-6
'------------------------------------------------
Private Sub Form_Load()
wb1.Navigate2 "d:\1.html"
End Sub
Private Sub wb1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
Debug.Print URL
If URL = "http://www.baidu.com/" Then
getFrames(wb1).Document.All("kw").Value = "¹È¸è"
MsgBox getFrames(wb1).Document.All("kw").Value
End If
End Sub
'WBΪҪ´¦ÀíµÄwebbrowser
Private Function getFrames(ByVal WB As WebBrowser) As Object
Dim pContainer As olelib.IOleContainer
Dim pEnumerator As olelib.IEnumUnknown
Dim pUnk As olelib.IUnknown
Dim pBrowser As SHDocVwCtl.WebBrowser_V1
Set pContainer = WB.Object.Document
If pContainer.EnumObjects(OLECONTF_EMBEDDINGS, pEnumerator) = 0 Then
Set pContainer = Nothing
Do While pEnumerator.Next(1, pUnk) = 0
Set pBrowser = pUnk
If Err.Number = 0 Then
Print "Frame: " & pBrowser.LocationURL
If pBrowser.LocationURL = "http://www.baidu.com/" Then '¿ÉÒÔÔÚÕâÀï¼ÓÌõ¼þÅжϵõ½Ö¸¶¨µÄframe£¬»ù±¾¿ÉÒÔ¸ù¾Ýurl»òÕßinnerHTMLÖеÄij¸ö¹Ø¼ü×Ö·û
Set getFrames = pBrowser
Exit Function
End If
End If
Loop
Set pEnumerator = Nothing
End If
End Function