From WebPageA to WebPageB: Error . . . windows opener document isnull or is not an object

R

ryguy7272

Hello experts. Last week I got some GREAT help from Peter Schleif.
Thanks! Learned a ton!!

I have a question different from my original post, so I’m starting a
new thread specifically for this.

Basically, I’m entering data into a few HTML-based ComboBoxes, and
this stuff works fine. I’m also navigating from a pageA (first page)
to a pageB second page. I’m copying data from a sheet into a TextBox
in a web page. This seems to work (data goes from sheet to TextBox),
but when I look closely, I notice a small exclamation mark and a small
yellow triangle . . . there is an error on this page. Basically, when
I go from pageA to pageB, I noticed an error message, described below:
windows opener document is null or is not an object

As I alluded to above, I seem to be able to copy/paste data from the
Sheet into the TextBox named "pasteProfitCenter", but the next snippet
of code fails:
Set itm = ie.document.getElementsByTagName("input")
For Each oHTML_Element In ie.document.getElementsByTagName("input")
If oHTML_Element.Type = "button" And _
oHTML_Element.Value Like "*Validate-->*" Then
oHTML_Element.Click:
Next

That's when I noticed the error: windows opener document is null or
is not an object
Since web pages are stateless, I think this pageB is looking for
information from pageA, but not seeing it, and this is why I can't
find this element: oHTML_Element.Value Like "*Validate-->*"

I KNOW THAT 'VALIDATE' ELEMENT IS IN THAT PAGEB!! But, Excel keeps
telling me it is NOT there. I Googled around for a couple days, and
did some research on this error, but didn’t find anything helpful.
Here is the structure on the page:
<td class="moap-td-form-obj">
<textarea name="pasteProfitCenter" id="pasteProfitCenter"
onfocus="javascript:selAll();" rows="8" cols="40">
<input onclick="javascript:validateProfitCenter();" type="button"
value="Validate-->"/>

Again, haven't found much about dealing with that error message. Has
anyone ever experienced this before?
It's weird that pageB can accept the list/array from the sheet,
because pageB is referenced this way:
Set itm = ie.document.getElementById("pasteProfitCenter")
In the next step, I'm trying to reference the pageB using a similar
concept:
Set itm = ie.document.getElementsByTagName("input")
For Each oHTML_Element In ie.document.getElementsByTagName("input")
If oHTML_Element.Type = "button" And _
oHTML_Element.Value Like "*Validate-->*" Then
oHTML_Element.Click:
Next

I think I’m out of ideas right now, but I don’t want to give up on
this. Does anyone know of a way to do this? I’m a little out of my
comfort zone with some of this stuff. I told a guy at work I’d help
him with a project he is working on, but now I’m stuck!!
 
N

norie

Excel is really just telling you there's a problem, it's not causing
it.

The actual problem must be somewhere on the page

I know you insist the input you are looking for is there, but are you
actually looking 'there'.

eg is the right page being looked at

This sort of thing is pretty common and sometimes it can be difficult
to find the root of the problem.

It could be that the 2nd page hasn't fully/correctly loaded - the
script error might be indicative of that.

The object part of the error suggests that the code the click event is
calling is not receiving the correct arguments.

Working with webpages can be quite tricky because there aren't really
any overall, generic approachs - it can all depend on
how things have been designed.

It's also pretty hard to debug this sort of thing without more
information.

By the way the code you've posted doesn't actually seem to reference
pageB, if there is more code post it.:)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top