NotesUIWorkspace not set

I have a problem with NotesUIWorkspace. The following code, to my mind, should return a valid NUIW class instance, which is not happening:

dim ws as new notesuiworkspace

The code is in the queryopen event of a form and the document using the form is being opened from an embedded view on a page in the notes client (this is happening with Notes V5.10 and V6.0)

Lastly, this code ran well up until a little while ago when everything stopped happening. Having looked at the database properties, the db was badly in need of compacting. Would this have had any effect?

Thanks in advance for any help that might come my way.

Matt