Home Forums General XMetaL Discussion Document.getDocumentObject() returns Null Reply To: Document.getDocumentObject() returns Null

Derek Read

Reply to: Document.getDocumentObject() returns Null

I have no idea why things would be failing when the computer sleeps. I assume you wake it up as a user by moving the mouse or by a key press?

The fact that calling Reload() is triggering the “choose DTD” dialog means that the DTD cannot be found. The same prompt should also occur when the document is first opened. But if it doesn't then I guess your changes to the file are removing the DOCTYPE declaration or changing it after open? I'm sort of shooting in the dark here.

Instead of calling Reload() you might wish to try Application.PostSetFocus(1). My suspicion is that putting focus back into the active document might help, though I can't say why focus is moving out of the document. Either way, calls to the ActiveDocument should function regardless of whether focus is actually in the document. These are just guesses at this point since the last thing that occurs when you call Reload() is to restore the user's selection (and therefore focus) in the document.