[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 703
  • Last Modified:

Editing in the Microsoft Web Browser Control

Hi I'm trying to use the Microsoft Web Browser control in an Access 2000 application to allow users to make minor changes to HTML script before it gets dumped into Oulook and despatched...

The story so far ... ok I've managed to find out that you use the following

Me.axMWB.Navigate "C:\ODA\ADO.htm"
Me.axMWB.Document.designmode = "on"

to load a document and get get the control in edit mode ... my issues are now

1. How to insert a new line. When the user presses the Enter Key it simply moves the focus off the control ... do I have to write some come of event capture code to put in a <BR> ?  Surely there must be an easier way.  I've tried various key combinations e.g. Ctrl-enter etc but they don't seem to work

2.  How to save the document. OK if I re run the navigate method it offers to save the existing changes (along with microsoft's tags) but there must be a neater way than this.

Thanks in advance

Nat
0
Natchiket
Asked:
Natchiket
  • 4
  • 3
1 Solution
 
pjcrooks2000Commented:
Nat seems that the region you are using for editing is not an editable area

Try in your code setting text area so that it is enabled

if you text area was called txtHtmlArea then do this

txtHtmlArea.enabled = True

You may need to hunt around in your code to find the correct place to put this.  By enabling the editable area you can go in and add whatever text you like to it.

Cheers
0
 
NatchiketAuthor Commented:
Well it allows the insertion of ordinary characters just not line breaks, so does that mean that the area is editable?

I'm not familiar with the concept of text areas within the web browser control, is this something I need to check out just for allowing line breaks ?
0
 
edwardiiiCommented:
Hi, Natchiket.

Regarding auto-saving edits to your WebBrowser control without the popup, you can use the following (for example in a command button "Save" or in the WebBrowser's BeforeNavigate2 method:

'Private Sub cmdExit_Click()
    WebBrowser1.ExecWB OLECMDID_SAVE, OLECMDEXECOPT_DONTPROMPTUSER
'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)
    If WebBrowser1.LocationURL <> "" Then WebBrowser1.ExecWB OLECMDID_SAVE, OLECMDEXECOPT_DONTPROMPTUSER
'End Sub

Regarding the issue you're experiencing with using the Enter key, I notice if I have no command buttons set as default then hitting Enter in the WebBrowser control inserts a new line.  If any of my command buttons are set with Default  = True, then a new line is not inserting in the WB control.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
NatchiketAuthor Commented:
thanks edwardiii, the saving aspect certainly works,

however I'm still having problems with the enter key.

I've tried removing all command buttons from the form and now when enter key is pressed, the insertion point just stays where it is, mocking me with it's unmovingness.....
0
 
NatchiketAuthor Commented:
OK have found a solution at www.lebans.com, it's pretty involved.
0
 
edwardiiiCommented:
Hi, Natchiket.

I've found a way to determine when someone has clicked on your WebBrowser control, and then add a blank line at that point in the HTML document being worked on with designmode = "on".

First, add the following to your General Declarations:

     Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
     Dim WithEvents wbDoc As HTMLDocument

Next, add the code below to your WebBrowser's DocumentComplete method:

     Set wbDoc = WebBrowser1.Document
   
Then add the following function to your project (for example, under the DocumentComplete event):

     Private Function wbDoc_onkeypress() As Boolean  
         If GetAsyncKeyState(vbkeyreturn) < 0 Then
              wbDoc.execCommand ("insertParagraph")
         End If  
    End Function

Now you should get the functionality you're looking for as regards your question # 1 above.  For more details on all the options you can use with "execCommand", see:

     http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/methods/execcommand.asp

For more info regarding working with editable Web pages, see:

     http://www.itjungle.com/mpo/mpo102402-story02.html
0
 
NatchiketAuthor Commented:
Thanks edwardiii I haven't tried your solution but it looks good, as I mentionned www.lebans.com has a solution, in fact there's a downloadable Access web editor (using the browser contol)
Many thanks for your efforts
0
 
edwardiiiCommented:
:)
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now