Fill VBA Web Form Rich Text

wiedf

New Member
Joined
Jul 26, 2017
Messages
3
Hi,

I've searched quite extensively for the answer to this question but can't seem to find a solution, hopefully somebody can help me out.

I'm trying to fill in a form on a web page, but the form contains a text box that uses rich text. I can't find a way of filling in the text box. The rich text box does have a hidden field before it which it is associated with and I can use vba to fill this in but the validation on submitting the form fails because the rich text box is not complete.


I've included some snippets from the code below to try and give you the general idea of what I'm trying to do:

HTML:
 			<textarea tabindex="3" name="description" cols="80" rows="10" style="visibility: hidden; display: none;"></textarea><div id="cke_description" class="cke_1 cke cke_reset cke_chrome cke_editor_description cke_ltr cke_browser_gecko" dir="ltr" role="application" aria-labelledby="cke_description_arialbl" lang="en"></div>

The vba code that I have at the moment:


Code:
  Sub Vba2HtmlForm()   

  Dim ie      As Object


   Dim frm     As Variant
   Dim element As Variant
   Dim wb As Workbook
   Set wb = ThisWorkbook

   Set ie = CreateObject("InternetExplorer.Application")
   ie.navigate "web form"
   
   While ie.readyState <> 4: DoEvents: Wend


   Set frm = ie.document.getElementsByName("report_bug_form").Item(0)


   Set evt = ie.document.createEvent("HTMLEvents")

   ie.Visible = True


   frm.elements("description").Value = "Description ......."



End Sub

Thanks for any help in advance
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Have a go with the following, I've had success with this with text boxes on web forms but haven't tried it with rich text

Code:
Private Sub CommandButton1_Click()
Dim ie As SHDocVw.InternetExplorer
Set ie = New SHDocVw.InternetExplorer




ie.Visible = True
ie.Navigate "web address of form"


Do
DoEvents
Loop Until ie.ReadyState = 4


'Find text box and enter value
Call ie.Document.GetElementById("id of text field").SetAttribute("value", Textbox1.Value)


'Search inputs to find submit button then click on it
Set AllInputs = ie.Document.GetElementsByTagName("input")
    For Each hyper_link In AllInputs
        If hyper_link.Name = "id of submit button" Then
            hyper_link.Click
            Exit For
        End If
    Next
Do
DoEvents


Loop Until ie.ReadyState = 3
Do
DoEvents


Loop Until ie.ReadyState = 4


ie.Quit


Unload Me
End Sub
 
Upvote 0
Thanks for that - although I can't seem to see how that is any different form what I'm doing a the moment. The problem is the rich text box is in its own iframe and so cannot be accessed through the method I used before. The rich text editor is ckeditor.
 
Upvote 0
Probably best to keep looking, Sorry I couldn't be of anymore help to you. That example is what I use now on a very basic page. It's actually from an answer to a question I asked here.
 
Upvote 0
No problem - thanks for trying. In fact I've just managed to work this out using the code below:

Code:
IE.document.getElementsByTagName("iframe")(0).contentDocument.getElementsByTagName("body")(0).innerText = "description"
 
Upvote 0
That's cool. It works for me as well.

I am able to put my "description" text in the html body of the iframe. I can confirm this by looking into the source code.
But, I am not able to see it one the screen -> in the text editor

Can you help me with this?
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,853
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top