日期:2012-11-10  浏览次数:20420 次

1、如何使网页不出现滚动条:

Private Sub mnuScroll1_Click()
'注意:必须在网页完全显示之后才可以运行
WebBrowser1.Document.body.Scroll = "no" '不显示滚动条的办法
End Sub
Private Sub mnuScroll2_Click()
'注意:必须在网页完全显示之后才可以运行
WebBrowser1.Document.body.Scroll = "Auto" '显示滚动条的办法
End Sub




2、如何获得网页中被选中部分的HTML:

Private Sub Command1_Click()
Dim objSelection
Dim objTxtRange

Set objSelection = WebBrowser1.Document.selection
If Not (objSelection Is Nothing) Then
Set objTxtRange = objSelection.createRange
If Not (objTxtRange Is Nothing) Then
Debug.Print objTxtRange.htmlText

Set objTxtRange = Nothing
End If
Set objSelection = Nothing
End If
End Sub

Private Sub Form_Load()
WebBrowser1.Navigate "http://www.applevb.com"
End Sub