Bryan Davies Bryan Davies - 8 months ago 23
HTML Question

How to run website forms in Excel without having to use Sendkeys?

I am trying fill out a form on a website using Excel VBA. I have created an InternetExplorer.Application, navigated to the page and looked up a bunch of data, using

If UserForm1.TC2.Value = True Then
or something like
PostCode = objIE.document.getElementsByName("ProjectFile-ProposalAddress-PostCode")(0).Value
and the like.

Afterwards, I navigate to a new page, and look to fill it out using my previous data.

And this is where I run into trouble. I want to tick a check box 'New Permit', and its code is;

<form id="document-form">
<div class="generate-form form-horizontal">
<div class="form-group"><label class="col-sm-3 control-label"><span>New Permit</span></label><div class="input col-sm-7">
<div class="checkbox">
<input type="checkbox" data-bind="checked: NewPermit" />
</div></div></div><div class="form-group"><label class="col-sm-3 control-label"><span>Staged Permit</span></label><div class="input col-sm-7">
<div class="checkbox">
<input type="checkbox" data-bind="checked: StagedPermit" />

Which has no name to lock into. I'm not a HTML expert, but there is some more code that refers to this tickbox (I think)

var model = { "NewPermit": null, "StagedPermit": null, "AmendedPermit": null,


I have run a loop through the code using
with various
etc. The following results is for the New Permit box:

= Span

= New Permit

= New Permit

= False

= [object HTMLSpanElement]

= ""

This is behind a password log in, and I cannot post the link publicly. But can work through PM etc to get to the answer.


Use getElementsByTagName('input') and then use Checked = True

Dim element as Object
element = getElementsByTagName('input')
element.Checked = True

assumes checkbox is the only input element on the page. If not, make a loop and identify the desired checkbox