For whats it worth, my guess is that the script is not properly (fully) syncing-up when fetching the Document Object from Internet Explorer.

The Navigate method call is asynchronous - it returns emmediately - and the Document object isn't "ready" until the navigation fully completes. The way to handle this is to perform the navigate, then enter a tight loop waiting for it to finish, then "fetch" your Document object handle, here's an exmaple using your script:

; Get a handle to the open document ...

$doc = $ie.document

while $ie.busy and $ie.readystate <> 4 and @error = 0 loop

$doc.write($html)


Hope this helps.

-Shawn