I was wondering how to open a html file so you can view and edit the code in a text box?
Anyone know would be helpful
Printable View
I was wondering how to open a html file so you can view and edit the code in a text box?
Anyone know would be helpful
Either use MSInet:
Or use the ShDocVw.Dll (Webbrowser) Control:Code:Text1.text = Inet1.OpenURL("http://www.site.com")
Code:Text1.Text = Webbrowser1.Document.documentElement.innerHTML
sorry i ment to open from a hard drive or disk
Well, using MSInet, you have to be connected. But Webbrowser way, you do not have to be connected.
Code:'Put this code in the form declarations:
Dim modified As Integer
'Modifed 0 = not changed
'Modifed 1 = changed
Private Sub Form_Load()
modified = 0
Webbrowser1.Navigate "C:\htmlfile.htm"
Text1.Text = Webbrowser1.Document.documentElement.innerHTML
End Sub
Private Sub Text1_Change()
modified = "1"
End Sub
Private Sub Form_Unload(Cancel As Integer)
If modified = 1 Then
'file has been edited!
Open "C:\htmlfile.htm" For Output As #1
Print #1, Text1
Close #1
Unload Me
Set form1 = Nothing
End
Else
'no change has been made
Unload Me
Set form1 = Nothing
End
End If
End Sub