Problem on queryopen R7

On lotus notes 5 below script is working , but in ln R7 i have error “Object variable Not set”

Sub Queryopen(Source As Notesuidocument, Mode As Integer, Isnewdoc As Variant, Continue As Variant)

Dim session As New NotesSession

Dim ws As New NotesUIWorkspace

Dim doc As NotesDocument

Set doc = ws.CurrentDocument.Document

End Sub

why above script “Set doc = ws.CurrentDocument.Document” not working in R7 ?

need help please,.

Subject: problem on queryopen R7

If its a new document, the currentdocument property is not set until the document is saved.