Re: HOWTO Use WebBrowser Control to Open & Edit HTML File

Tech-Archive recommends: Speed Up your PC by fixing your registry



Thank 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.

For example, assume the text reads as follows in the doc template:

"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!

"Larry Serflaten" <serflaten@xxxxxxxxxxxxxx> wrote in message
news:uHeO5jtHGHA.1124@xxxxxxxxxxxxxxxxxxxxxxx
>
> "Dan Johnson" <johnson@xxxxxxxxxx> wrote
> > We're using the Webbrowser control to display html help documents
(stored
> > locally) to our users. We need to be able to access the body text of
the
> > html document both for purposes of editing the text and searching the
text.
> > I started palying with the Webbrowser.Document property, but I'm getting
> > nowhere fast. Can anybody give me reference here? We do not
necessarily
> > have 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).
> Then paste in the code below:
>
> 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)
> If 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
>
>
>


.


Quantcast