"Object Variable Not Set" when accessing CurrentDocument in R6

R6 has trouble getting a handle on the currentdocument from the NotesUIWorkspace. The example below was is a dialog box that was called from an agent. The solution was to use the source handle on the notesuidocument rather than retrieve it from the uiworkspace
LotusScript

ORIGINAL CODE

Sub Postopen(Source As Notesuidocument)
	
	Dim workspace as new notesuiworkspace
	Dim session As New NotesSession
	Dim User As String
	User = session.commonusername
	Dim thisdb As NotesDatabase
	Set thisdb = session.CurrentDatabase
	Dim profileview As NotesView
	Set profileView = thisdb.GetView("User Profiles")	
	Dim uidoc as notesuidocument
	Set uidoc = workspace.currentdocument
	Dim doc As notesdocument
	Set doc = uidoc.document

End Sub

FIX CODE

Sub Postopen(Source As Notesuidocument)
	
	Dim session As New NotesSession
	Dim User As String
	User = session.commonusername
	Dim thisdb As NotesDatabase
	Set thisdb = session.CurrentDatabase
	Dim profileview As NotesView
	Set profileView = thisdb.GetView("User Profiles")	
	Dim doc As notesdocument
	Set doc = source.document

End Sub

Posted by fbrefere001 on Thursday September 11, 2003