
Object doesn't support this property or method
Hi there,
I am having difficulty with a problem that I hope someone has solved in the
past
In the following snippet of code (part of a sub), I open a new browser
window and save a reference to it. Then, using the Document Object Model (as
I understand it) I step down through the hiearchy trying to get a reference
to an OCX in the html page. The OCX is placed in the page with an <Object>
tag and has a name assigned to it via the parameter NAME="VBFORM".
set projFormx = window.open("testocx.htm", "",
"scrollbars=no,status=no,toolbar=no,menubar=no,resizeable=no,width=570,heigh
t=670")
set myDocx = projFormx.document
set myAllx = myDocx.all
set myObjx = myAllx.VBFORM
What happens is that the script fails on the last line of this snippet,
where it tries to reference the OCX in the all collection. A message box
pops up saying that
Object doesn't support this property or method
and further in the script where I try to use the myObjx to call methods on
the object, this will also fail.
The problem I have is particulary damning because it only occurs the first
time in each Explorer session that I execute the code in the sub. Subsequent
times, this problem does not happen. However, we cannot exactly say to our
client that he only has to put up with the error message the first time in
each session.
I suspect that the problem is occuring because the testocx.htm is trying to
reference an object (named VBFORM) which may not have finished loading yet
and so it fails. However, when the second, third or nth time that the sub is
called, the VBFORM object may already be in a cache or in memory or
something so it loads without error messages. Being as I'm pretty certain
that VBScript is NOT a threaded langauge, we cannot start a thread which
loads the page and join() the thread after it completes so that the line
set myObjx = myAllx.VBFORM
results in a valid call. Is there another way to solve this? Any help would
be appreciated.
Cesar