I'm trying to use VBA to automatically post adverts on this website called Gumtree. I've been successful with getting VBA to fill up the HTML form input fields but am now stuck at getting the description box iframe to register the new outerHTML.
Here is the website: Gumtree Post
This is the procedure of posting:
The Description Box is an iFrame embedded in the HTML Document. Before filling in anything, this is the HTML code of the iFrame:
<code style="margin: 0px; padding: 0px; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: inherit;"><!--</font-->DOCTYPE HTML PUBLIC"-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv="content-type" content="text/html; charset=UTF-8">
<STYLE>body {background:#FFFFFF;margin:0px;padding:0px;text-align:left;font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size:0.875em;}.desc{color:gray;} body.error{ background-color:#EFDBD6;} body.valid { background-color:#F0FFC1; color :#468847;} P {margin-top:0;margin-bottom:0}a{text-decoration: none;color:#000}<!--</font-->STYLE>
<!--</font-->HEAD>
<BODY id="rte">
<P class="desc"><!--</font-->P><!--</font-->BODY><!--</font-->HTML></code>
Manually keying in words into the description box gives a new html of: (Note the body tag with an additional attribute of class="valid" that makes the iframe accept the input:
<code style="margin: 0px; padding: 0px; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: inherit;"><!--</font-->DOCTYPE HTML PUBLIC"-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv="content-type" content="text/html; charset=UTF-8">
<STYLE>body {background:#FFFFFF;margin:0px;padding:0px;text-align:left;font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size:0.875em;}.desc{color:gray;} body.error{ background-color:#EFDBD6;} body.valid { background-color:#F0FFC1; color :#468847;} P {margin-top:0;margin-bottom:0}a{text-decoration: none;color:#000}<!--</font-->STYLE>
<!--</font-->HEAD>
<BODY class="valid" id="rte">
<P>I typed this manually!<BR><!--</font-->P><!--</font-->BODY><!--</font-->HTML>
</code>This is what I've tried to do to fill in the description box using VBA:
<code style="margin: 0px; padding: 0px; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: inherit;">IE.Document.getElementsByTagName("iframe")(0).contentDocument.getElementsByTagName("body")(0).innerHTML ="This is posted using VBA.
"</code>And this as well:
<code style="margin: 0px; padding: 0px; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: inherit;">IE.Document.getElementsByTagName("iframe")(0).contentDocument.getElementsByTagName("body")(0).outerHTML ="This is not working too!
</code>
So this is what my VBA can achieve using both codes:
<code style="margin: 0px; padding: 0px; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: inherit;"><!--</font-->DOCTYPE HTML PUBLIC"-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv="content-type" content="text/html; charset=UTF-8">
<STYLE>body {background:#FFFFFF;margin:0px;padding:0px;text-align:left;font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size:0.875em;}.desc{color:gray;} body.error{ background-color:#EFDBD6;} body.valid { background-color:#F0FFC1; color :#468847;} P {margin-top:0;margin-bottom:0}a{text-decoration: none;color:#000}<!--</font-->STYLE>
<!--</font-->HEAD>
<BODY class="error" id="rte">
<P>VBA cannot fill this in without error!<BR><!--</font-->P><!--</font-->BODY><!--</font-->HTML>
</code>I noticed that the important thing I need to achieve is getting the body tag to include this new attributeclass="valid" so that there would be no error. Yet even after manually editing it to class="valid" I still get class="error" instead and I am thus unable to proceed.
Here is the website: Gumtree Post
This is the procedure of posting:
- Under "Choose a location", select any random location
- Under "Choose a category", select Jobs > Part-Time Jobs > Other Part-Time Jobs
- Under "Information of the ad", I am stuck at filling up the Description Box
The Description Box is an iFrame embedded in the HTML Document. Before filling in anything, this is the HTML code of the iFrame:
<code style="margin: 0px; padding: 0px; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: inherit;"><!--</font-->DOCTYPE HTML PUBLIC"-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv="content-type" content="text/html; charset=UTF-8">
<STYLE>body {background:#FFFFFF;margin:0px;padding:0px;text-align:left;font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size:0.875em;}.desc{color:gray;} body.error{ background-color:#EFDBD6;} body.valid { background-color:#F0FFC1; color :#468847;} P {margin-top:0;margin-bottom:0}a{text-decoration: none;color:#000}<!--</font-->STYLE>
<!--</font-->HEAD>
<BODY id="rte">
<P class="desc"><!--</font-->P><!--</font-->BODY><!--</font-->HTML></code>
Manually keying in words into the description box gives a new html of: (Note the body tag with an additional attribute of class="valid" that makes the iframe accept the input:
<code style="margin: 0px; padding: 0px; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: inherit;"><!--</font-->DOCTYPE HTML PUBLIC"-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv="content-type" content="text/html; charset=UTF-8">
<STYLE>body {background:#FFFFFF;margin:0px;padding:0px;text-align:left;font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size:0.875em;}.desc{color:gray;} body.error{ background-color:#EFDBD6;} body.valid { background-color:#F0FFC1; color :#468847;} P {margin-top:0;margin-bottom:0}a{text-decoration: none;color:#000}<!--</font-->STYLE>
<!--</font-->HEAD>
<BODY class="valid" id="rte">
<P>I typed this manually!<BR><!--</font-->P><!--</font-->BODY><!--</font-->HTML>
</code>This is what I've tried to do to fill in the description box using VBA:
<code style="margin: 0px; padding: 0px; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: inherit;">IE.Document.getElementsByTagName("iframe")(0).contentDocument.getElementsByTagName("body")(0).innerHTML ="This is posted using VBA.
"</code>And this as well:
<code style="margin: 0px; padding: 0px; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: inherit;">IE.Document.getElementsByTagName("iframe")(0).contentDocument.getElementsByTagName("body")(0).outerHTML ="This is not working too!
</code>
So this is what my VBA can achieve using both codes:
<code style="margin: 0px; padding: 0px; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: inherit;"><!--</font-->DOCTYPE HTML PUBLIC"-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv="content-type" content="text/html; charset=UTF-8">
<STYLE>body {background:#FFFFFF;margin:0px;padding:0px;text-align:left;font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size:0.875em;}.desc{color:gray;} body.error{ background-color:#EFDBD6;} body.valid { background-color:#F0FFC1; color :#468847;} P {margin-top:0;margin-bottom:0}a{text-decoration: none;color:#000}<!--</font-->STYLE>
<!--</font-->HEAD>
<BODY class="error" id="rte">
<P>VBA cannot fill this in without error!<BR><!--</font-->P><!--</font-->BODY><!--</font-->HTML>
</code>I noticed that the important thing I need to achieve is getting the body tag to include this new attributeclass="valid" so that there would be no error. Yet even after manually editing it to class="valid" I still get class="error" instead and I am thus unable to proceed.