Extending HTML Editor in Access

  • Thread starter Thread starter ridders
  • Start date Start date
R

ridders

Hi

I've used Stephen Lebans SHTML Editor utility to create a form at start up
alerting users to new database features. Have extended this with undo / redo
icons etc. This form is used together with code which dims the background
when the HTML message is displayed. The idea is that users will hopefully
read the info ...I've given up on help files which no-one ever reads! Happy
to forward the relevant items to anyone who is interested.

I'd like to extend the features further but am unable to find any
documentation about using the WBrowser control. For example, I would like to
add a button to add an image rather than right click the WBrowser control.
Also Insert Hyperlink...

Can anyone give me any ideas on how to proceed or websites with relevant info
 
A couple of years ago a user Emailed me code to insert Tables into the MS
Web Browser control. I just spent a full 10 minutes looking for it but with
no luck. YOu should be able to find what you need with a GoogleGRoups
search.

Good luck. If you find it please let me know.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
Hi Stephen

Thanks for reply and for the many excellent examples on your website.

I have successfully added Undo / Redo / Create Link / Insert Picture /
Insert Horizontal Line to the WebBrowser control. Justify Full doesn't work.
MSDN article lists various other items listed as available in WebBrowser
including Create Bookmark / Insert Frame but not Insert Table.

In fact your website has some code to insert a table suggested by a user.
I've tried it and it adds a 2x2 table but deletes all existing HTML code in
the WebBrowser! A major defect!

My code is shown below. Message box used to warn user of issue!
Any thoughts on how to fix this would be appreciated
===========================
Private Sub cmdTable_Click()

'Next line not supported
'Me.WBrowser.Object.Document.execCommand "InsertTable", True, Null

'This inserts a table but removes all existing code!
Dim Msg, Style, Title, Response, MyString

Msg = "This inserts a 2x2 table. " & vbNewLine & _
"NOTE: All existing HTML code wil be removed. " & vbNewLine & vbNewLine & _
"Are you sure you want to do this? "

Style = vbYesNo + vbInformation + vbDefaultButton2 ' Define buttons.
Title = "WARNING" ' Define title.
Response = MsgBox(Msg, Style, Title)
'If user chooses No, return to selection box.
If Response = vbNo Then Exit Sub
'If user chooses Yes, insert table

With Me.WBrowser.Document
..writeln "<table>"
..writeln "<tr><td>A1</td>"
..writeln "<td>B1</td>"
..writeln "</tr>"
..writeln "<tr><td>A2</td>"
..writeln "<td>B2</td>"
..writeln "</tr>"
..writeln "</table>"

End With

End Sub

=======================================
The other bug I have is that the Undo command works too well! After undoing
each change made it will eventually delete all HTML in the window! Very odd!
Thankfully the Redo command restores it!
 
I have done a workround which partly solves the problem with InsertTable.
Existing code is copied to clipboard then pasted after table added.
The table is then placed at end of code but it can be moved afterwards.

Updated code is:
================================
Private Sub cmdTable_Click()

'Next line not supported
'Me.WBrowser.Object.Document.execCommand "InsertTable", True, Null

'This inserts a table at end of existing code!
Dim Msg, Style, Title, Response, MyString

Msg = "This inserts a 2x2 table at the end of the HTML message. " &
vbNewLine & _
"This can be moved later by dragging & dropping" & vbNewLine & vbNewLine & _
"Are you sure you want to create a table? "

Style = vbYesNo + vbInformation + vbDefaultButton2 ' Define buttons.
Title = "WARNING" ' Define title.
Response = MsgBox(Msg, Style, Title)
'If user chooses No, return to selection box.
If Response = vbNo Then Exit Sub
'If user chooses Yes, insert table

'first copy all existing HTML code to clipboard
Me.WBrowser.Object.Document.execCommand "SelectAll", False, Null
Me.WBrowser.Object.Document.execCommand "Copy", False, True

'Add the 2x2 table
With Me.WBrowser.Document
..writeln "<table>"
..writeln "<tr><td>A1</td>"
..writeln "<td>B1</td>"
..writeln "</tr>"
..writeln "<tr><td>A2</td>"
..writeln "<td>B2</td>"
..writeln "</tr>"
..writeln "</table>"
End With

'paste the original code from the clipboard
Me.WBrowser.Object.Document.execCommand "Paste", False, True

End Sub
===================================
It may be that creating a bookmark and somehow using SendKeys to move to the
bookmark would allow me to place the table precisely...but I haven't worked
out how this could be done.
 
I would encourage you to seek help with this issue over in one of the HTML
related NG's. I have a date with a plane tomorrow to Mexico and won't be
available for a week.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
Playing a bit with Stephens Access based HTML Editor, I wanted to
insert text within the HTML too.

I found that the execCommand "Paste", although would not accept a
string argument, would accept the value of a text box or combo as the
value to paste in - therefore allowing you to insert any text at the
cursor location!

Try this:

Private Sub cmdTable_Click()

'Next line not supported
'Me.WBrowser.Object.Document.execCommand"InsertTable", True, Null

Me.txtTable = "<table>" _
& "<tr><td>A1</td>" _
& "<td>B1</td>" _
& "</tr>" _
& "<tr><td>A2</td>" _
& "<td>B2</td>" _
& "</tr>" _
& "</table>"

Me.WBrowser.Document.execCommand "Paste", True, txtTable.value
'Pastes value of control txtTable, rather than clipboard contents!
Clipboard remains in tact!
'Unfortunately the HTML will be visible, rather than inserted into the
innerhtml

End Sub


Next to figure out how to paste directly to the innerhtml

Matt Brown
 
Back
Top