掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
Webブラウザコントロールで検索をするには? (ID:90046)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
> 表示されているドキュメントのある文字列をマウスでドラッグ反転し、 > それと同じ文字列を反転文字列以降の位置から検索しようとする場合です。 こういうことでしょうか? Option Explicit Private WithEvents Doc As HTMLDocument Private moRng As IHTMLTxtRange Private msText As String Private Sub Command1_Click() If moRng Is Nothing Then Exit Sub If moRng.findText(msText) Then moRng.Select moRng.scrollIntoView moRng.collapse False Else MsgBox "検索終了" Set moRng = Nothing End If End Sub Private Sub WebBrowser1_BeforeNavigate2(ByVal pDisp As Object, URL As Variant, Flags As Variant, TargetFrameName As Variant, PostData As Variant, Headers As Variant, Cancel As Boolean) Set Doc = Nothing End Sub Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant) Set Doc = WebBrowser1.Document End Sub Private Function Doc_onclick() As Boolean Dim selRng As IHTMLTxtRange Set selRng = Doc.selection.createRange msText = selRng.Text If Len(msText) Then Set moRng = Doc.body.createTextRange moRng.moveToBookmark selRng.getBookmark moRng.moveStart "word" End If Set selRng = Nothing Doc_onclick = True End Function
←解決時は質問者本人がここをチェックしてください。
戻る
掲示板システム
Copyright 2020 Takeshi Okamoto All Rights Reserved.