PO
Thu Mar 10 23:52:04 CST 2005
Thanks Michael!
I tried your solution and it works perfectly.
Regards
PO
"Michael Harris (MVP)" <mikhar at mvps dot org> wrote in message
news:#qtOAGeJFHA.2752@TK2MSFTNGP10.phx.gbl...
> PO wrote:
> > Hi!
> >
> > I use the following lines to open a window in IE and insert the text
> > "Invoice no." into Sp1 (an OWC Spreadsheet component imbedded in
> > KFAKT.htm):
> >
> >
> > Dim wnd
> > Set wnd = window.open("KFAKT.htm", "")
> >
> > wnd.Sp1.Range("B10").Value = "Invoice no."
> >
> >
> > Most of the time the code works but sometimes I get an error message -
> > "Object doesn't support this propery or method: 'wnd.Sp1'".
> >
> > Any ideas?
>
> The window.open() method returns as soon as the window object is created
but
> the document will likely still be loading...
>
> An *ugly* solution is:
>
> Set wnd = window.open("KFAKT.htm", "")
> Do until window.document.readyState = "complete" : loop
>
> It's ugly because it goobles cpu cycles like crazy ;-)...
>
> A better solution would be to separate the creation of the window and
> document objects from the actual use of those objects...
>
> Dim the wnd variable at page level and use repeated setTimeout calls (or a
> setInterval with the returned interval id saved at page level that you
> eventually use to cancel with clearInterval) to check the readyState in a
> separately defined procedure (sub/function).
>
> In the procedure that calls window.open, use setTimeout or setInterval to
> start the checking procedure. The delay can be very short, say 10 to 50
> milliseconds.
>
> In that separate checking procedure, if the readyState is not "complete"
> then call setTimeout again (or wait for the next inteval). If it is
> "complete" then it's safe to use the window/document objects (no
additional
> setTimeout call or call clearInterval if you use that technique).
>
> setTimeout, setInterval, and clearInterval are documented at:
>
> DHTML Methods (Internet Explorer - DHTML)
>
http://msdn.microsoft.com/workshop/author/dhtml/reference/methods.asp?frame=
true
>
>
> --
> Michael Harris
> Microsoft MVP Scripting
>
http://maps.google.com/maps?q=Sammamish%20WA%20US
>
>