This is a follow up to this previous question:
I have the following script in the PostOpen event of a form sent to users:
Sub Postopen(Source As Notesuidocument)
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim redirectid As String
Set uidoc = workspace.CurrentDocument
redirectid = uidoc.FieldGetText( "DocID" )
Dim ws As New NotesUIWorkspace
Dim s As New NotesSession
Dim db As NotesDatabase
Set db = s.GetDatabase("servername"
Dim doc As notesdocument
Set doc = db.getDocumentByUNID(redir
Call ws.EditDocument(False, doc, True)
It does exactly what I need it to do except when users view their email in the preview pane. If the preview pane is open, when they click on the email, an error message appears stating: "Object Variable not Set". If the user then clicks to open the email, everything works fine.
How do I prevent this error? Is there a way to determine whether the email is being previewed and then only run the PostOpen script when the email is actually opened rather than previewed?