It's a pain in the neck, due to the complexity of
the IE DOM and the imprecision of HTML.
(If it really worked without problems then WYSIWYG
webpage editors would be easy to write and
would be actually useful.)
On the other hand, there is an amazing amount that you
can do with the IE DOM in a WB. If you set a reference
to MSHTML you'll get intellisense for the whole thing.
This example might be somewhat useful. It's a
WYSIWYG HTML editor written in VBScript - running
in an IE window - for the purpose of demonstrating
DOM functions and properties.
http://www.jsware.net/jsware/scripts.php3#domed
Doing it in VB is almost identical. It just
uses defined DOM objects through the MSHTML
type library, while script doesn't define variables
by type. The script sample might give you what you
want in terms of working out the methods you
need to accomplish what you want to do dynamically
in the page.
--
***@mindXXspring.com
(Remove Xs for return email.)
Post by Dan JohnsonThank you Ted and Larry.
I actually need to use elements of both of your ideas. Since I want the
WebBrowser control to be the user interface, I need to open a text file,
make necessary edits to the text, save the revised text, then reopen the
saved file via WebBrowser1.Navigate2. This allows me to customize the
terminology used in the document.
I also need to study the WebBrowser1.Document.documentElement.innerText
property. I hadn't seen this before, and think I might be able to use it to
save a step from above.
"Take a ride in the [Color] car."
I want to run Replace(MyText, "[Color]", "Blue") and transfer the revised
text to the WebBrowser control, but NOT have the changes saved to the
original document since the [Color] variable might change over time. Is the
WebBrowser1.Document.documentElement.outerHTML property writable so I can
open the *.html document using WebBrowser.Navigate2 then merely rewrite the
outerHTML property? I will need to play with this.
Again, Thanks!
Post by Larry SerflatenPost by Dan JohnsonWe're using the Webbrowser control to display html help documents
(stored
Post by Larry SerflatenPost by Dan Johnsonlocally) to our users. We need to be able to access the body text of
the
Post by Larry SerflatenPost by Dan Johnsonhtml document both for purposes of editing the text and searching the
text.
Post by Larry SerflatenPost by Dan JohnsonI started palying with the Webbrowser.Document property, but I'm getting
nowhere fast. Can anybody give me reference here? We do not
necessarily
Post by Larry SerflatenPost by Dan Johnsonhave to open/search the html file using the Webbrowser control BTW.
This may help you get a little farther along;
On a new form add a webbrowser, a textbox and button for the address
bar, and 2 option buttons to select the output (all using default names).
HTH
LFS
Private Sub Form_Load()
Command1.Caption = "Go"
Option1.Caption = "HTML"
Option2.Caption = "Text"
Option2.Value = True
Text1.Text = "www.google.com"
End Sub
Private Sub Command1_Click()
WebBrowser1.Navigate2 Text1.Text
End Sub
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As
Variant)
Post by Larry SerflatenIf pDisp = WebBrowser1 Then
If Option1 Then
Debug.Print WebBrowser1.Document.documentElement.outerHTML
Else
Debug.Print WebBrowser1.Document.documentElement.innerText
End If
End If
End Sub