In Word automation through OLE, when accessing the ActiveDocument property an exception will be raised if currently no visible document is available (at least in Delphi), so, my goal is to do some test like IsActiveDocumentValid, how to do that without raising an exception? Thank you!
In Word automation through OLE, when accessing the ActiveDocument property an exception will be
Share
The exception is raised by the automation server itself, you cannot prevent that. However you can get a count of open
Documentsbefore accessingActiveDocument;If the ‘Count’ is 0 if there are no documents available.
edit:
Alternatively you can handle the specific exception silently, example (Delphi code);