#1
|
|||
|
|||
GetElementsByName with memo box
Hi all,
I'm able to enter values into two IE form fields but not the third. I'm having trouble seeing why the same method would not work for the memo box as the textboxes. The boldfaced part of the code below is the part that does not seem to be registering. Any ideas? Thank you in advance for any assistance you can provide! Code:
Private Sub EmailBtnCWdown_Click() Dim ie As Object Set ie = CreateObject("internetexplorer.application") ie.Visible = True ie.Navigate ("https://mazzonicenter.freshdesk.com/support/tickets/new") Do Until ie.ReadyState >= 4 DoEvents Loop Set MCMemail = ie.Document.getElementsByName("helpdesk_ticket[email]")(0) MCMemail.Value = "Testing@testing.com" Set subj = ie.Document.getElementsByName("helpdesk_ticket[subject]")(0) subj.Value = "Testing" Set desc = ie.Document.getElementsByName("helpdesk_ticket[ticket_body_attributes][description_html]")(0) desc.Value = "Testing" End Sub |
#2
|
|||
|
|||
I'm just adding a few things for context. I don't know if memo box is the right term. It's a rich text area, so in that sense it is different than the other fields on the page.
Here is the code from the page source: Code:
<div class="control-group " > <label class=" required control-label description-label " for="helpdesk_ticket_description">Description</label> <div class="controls "> <textarea class=" required_redactor html_paragraph span12" cols="40" id="helpdesk_ticket_ticket_body_attributes_description_html" name="helpdesk_ticket[ticket_body_attributes][description_html]" rows="6"> </textarea> After some research, I'm wondering if we have to set the focus first, but I'm not sure how to do that or if that's even the problem. I have also tried using getElementByName but I get a 438 runtime error. Any ideas on how to populate this description box? Thank you! |
#3
|
|||
|
|||
Hope I'm not being a bug, but just wanted to see if anyone had any ideas about this one?
|
#4
|
|||
|
|||
From a Google search that took me to this page, this seems to work.
Code:
Sub FormFillTest() Dim ie As Object 'Open Internet Explorer Set ie = CreateObject("internetexplorer.application") 'have it visible ie.Visible = True 'go to the site ie.navigate ("https://mazzonicenter.freshdesk.com/support/tickets/new") 'wait until it's loaded Do Until ie.ReadyState >= 4 DoEvents Loop 'put email address in text box ie.document.getElementsByName("helpdesk_ticket[email]")(0).Value = "Testing@testing.com" 'put subject in text box ie.document.getElementsByName("helpdesk_ticket[subject]")(0).Value = "Testing" 'put something in the TEXTAREA ie.document.getElementsByClassName("redactor_editor")(0).innerText = "Hello World" End Sub |
#5
|
|||
|
|||
NoSparks, you are awesome.
I looked for several hours on a few days for this and just couldn't find it. And this question has stumped people in various forum threads over the years. Hopefully others will either find this thread in the future or have your intuition with the search (that was probably what was stumping me--just not searching for the right terms, but I suppose others who struggle with this might also be thinking along different lines). Thank you again, and congrats on solving one that has proven quite tough for many! |
#6
|
|||
|
|||
ps thank you for saving me from using SendKeys
|
#7
|
|||
|
|||
I don't know anything about this stuff.
Looked at it off and on for a couple of days thinking it should be straight forward. I had no success looking at things in IE with my older/slower computer but once I opened the website in FireFox and used its F12 inspector it was just a matter of using the element picker and watching as I typed in that textarea. From there did a search for how to write to a <div which got me to the page in the link. Pleased I could help and learned something along the way. |
#8
|
|||
|
|||
Yea I think my failure was just not finding the correct combination of what to call by (name/id/class) and the element itself. I had inspected through chrome/ie and tried various combinations but did not find redactor_editor.
Thanks again so much! |
Thread Tools | |
Display Modes | |
|