R6 Bug - NotesUIWorkspace.ComposeDocument

I have a lotus script procedure in script library where dialogbox and notesuiworkspace.composedocument are used to allow users to create a document of a different database. The program works fine in 5 but generates “Object variable not set” errors in 6.

Dim s As New NOTESSESSION

Dim ws As New NOTESUIWORKSPACE

Dim currUIDOC As NOTESUIDOCUMENT

Dim newUIDOC As NOTESUIDOCUMENT

Dim dc As NOTESDOCUMENTCOLLECTION

Dim currDB As NOTESDATABASE

Dim targetDB As NOTESDATABASE

Dim selDoc As NOTESDOCUMENT

Dim cfgdoc As NotesDocument

Dim corrdbs$



Dim tdoc As NOTESDOCUMENT

Dim flags$, pval$, pform$, pdbname$, pos%, tempV

Dim pickList As Variant



Set currDB = s.CURRENTDATABASE

Set currUIDOC = ws.CURRENTDOCUMENT

If Not currUIDOC Is Nothing Then

	If currUIdoc.ISNEWDOC Then

		Msgbox "Please save this document prior to creating others.", 0, "Please Save First"

		Exit Sub

	Elseif currUIdoc.DOCUMENT.HASITEM( "ZFromAgent" ) Then

		Msgbox "Please save this document prior to creating others.", 0, "Please Save First"

		Exit Sub

	End If

	Set seldoc = currUIDoc.DOCUMENT

Else

	Set dc = currDB.UNPROCESSEDDOCUMENTS

	If dc.COUNT > 0 Then

		Set selDoc = dc.GETFIRSTDOCUMENT

	End If

End If



pickList = GetCreateMenuOptions()



Set tdoc = currDB.CREATEDOCUMENT()

tdoc.pickList = picklist



If Not ws.DIALOGBOX("dlg-Menu", True, True, False, False, False, False, "Select Item To Create", tdoc) Then Exit Sub

pval = tdoc.PickedValue(0)

pos = Instr(1, pval, "~")

If pos = 0 Then Exit Sub

pform = Left( pval, pos-1 )

pdbname = Right( pval, Len(pval) - pos)

If isDebugger Then Print "Creating [" & pform & "] in [" & pdbname & "]  [" & pval & "]"



If Left( pdbname, 1 ) = "@" Then

	tempV = Evaluate( pdbname, tDoc )

	Set targetDB = New NOTESDATABASE( tempV(0), tempV(1) )

Else

	Set targetDB = dbhandle( pdbname )

End If

If Not targetDB.ISOPEN Then

	Msgbox "Unable to open database for creating document" & Chr(10) & _

	"Server [" & targetDB.SERVER & "]" & Chr(10) & "Path: [" & targetDB.FILEPATH & "]", 0, "Unable to Create"

	Exit Sub

End If



Select Case pform                   ' Handle Special Cases

Case "CP1"

      REM @If(Form != "CP"; @Do(@Prompt([OK]; "Position Error"; "Please position to a company or location profile to create a new location."); @Return("")); "");

      REM ENVIRONMENT PrevailMLValue := "0";

	If Ucase( currDB.FILENAME ) <> "PREVAIL.NSF" Then

		Msgbox "New Locations may only be created in the Prevail Contact Manager.", 0 , "Please Use Contact Manager"

		Exit Sub          '11/03/99  APL Added the exit sub so that a location is not composed when you are not in contact manager.

	Elseif seldoc Is Nothing Then       ' 11/03/99 APL Added because of Object variable not set error on seldoc.

		Msgbox "Please position to a company or location profile to create a new location.", 0, "Position Error"

		Exit Sub

	Elseif selDoc.FORM(0) <> "CP" Then

		Msgbox "Please position to a company or location profile to create a new location.", 0, "Position Error"

		Exit Sub

	End If

	Call s.SETENVIRONMENTVAR( "PrevailMLValue", "0", False )

	Set newUIDoc = ws.COMPOSEDOCUMENT( targetDB.SERVER, targetDB.FILEPATH, "CP" )

	

Case "PERSON"

	Call CreateNewContact48(selDoc)

Case "MEETING"

	Set newUIDoc = MenuOptionCreateMeeting()

Case "ACTREP1"

      REM @Environment("AISTATUS";"Complete");

	Call s.SETENVIRONMENTVAR( "AISTATUS", "Complete", False )

	Set newUIDoc = ws.COMPOSEDOCUMENT( targetDB.SERVER, targetDB.FILEPATH, "ACTREP" )

Case "ACTREP"    ' 10/04/99 APL Added to set the AISTATUs envirnement Variable.

    REM @Environment("AISTATUS";"Initial");

	Call s.SETENVIRONMENTVAR( "AISTATUS", "Initial", False )

	Set newUIDoc = ws.COMPOSEDOCUMENT( targetDB.SERVER, targetDB.FILEPATH, "ACTREP" )

	

 REM Added to support new Correspondence Manager  **Rock, 9/7/99

Case "LETTERS"

	If includeCorrespMenu()  Then 

		Call CorrespondenceWizard

	Else 

		Set cfgDoc = GetConfigDoc()

		Forall c In cfgDoc.SourceDBFileNames

			corrdbs = corrdbs & c & Chr(13)

		End Forall

		Msgbox "The Correspondence Manager is not configured to work with this Prevail Module." & Chr(13) &_

		"Please go to one of the following databases to access the Correspondence feature:" & Chr(13) & corrdbs, 0 , "Not Configured"

	End If

	

Case "QUICKENTRY"

	Set newUIDoc = ws.COMPOSEDOCUMENT( targetDB.SERVER, targetDB.FILEPATH, pform )

	On Event queryClose From newUIDoc Call CreateViewRefresh

	

Case "PP"

	If Not Ucase( currDB.FILENAME ) = "COMPDATA.NSF" Then               

		Msgbox "Competitive Product Profiles can only be created from the Competitive Data Database.",,"Use Competitive Data"

	Else

		If Not seldoc Is Nothing Then                    

			Set newUIDoc = ws.COMPOSEDOCUMENT( targetDB.SERVER, targetDB.FILEPATH, pform )

		Else

			Exit Sub

		End If

	End If

	

Case "IntellReport"

	If Not Ucase( currDB.FILENAME ) = "COMPDATA.NSF" Then

		Msgbox "Intelligence Reports can only be created from the Competitive Data Database.",,"Use Competitive Data"

	Else

		If Not seldoc Is Nothing Then                    

			Set newUIDoc = ws.COMPOSEDOCUMENT( targetDB.SERVER, targetDB.FILEPATH, pform )

		Else

			Exit Sub

		End If

	End If

	

Case Else                                   ' Handle Normal Cases                    

	Set newUIDoc = ws.COMPOSEDOCUMENT( targetDB.SERVER, targetDB.FILEPATH, pform )               

End Select          

End Sub

Subject: R6 Bug - NotesUIWorkspace.ComposeDocument

  1. Don’t post reams of code, especially when it’s out of context: how can you expect people to read all that, figure out what it is you’re trying to do, and then help you? Well, if you find someone like that, they’re a saint.

  2. If you insist on posting reams of code, at least pinpoint where you’re getting the OVNS error. Use the debugger, and half your battle is won. OVNS errors are soooooooooooooooooooo easy to track if you make effective use of the debugger and code judiciously (e.g. trap for certain objects such as NotesDocument and NotesView not being set, check for empty variants).

  3. Use Option Declare or Option Explicit to ensure you’re declaring everything that you should be – there are a number of variables that aren’t “typed” in your code that quite easily could be.

  4. This is almost certainly not due to a bug.

Subject: RE: R6 Bug - NotesUIWorkspace.ComposeDocument

Or it may in fact be due to a bug.Set currUIDOC = ws.CURRENTDOCUMENT

The CurrentDocument property of the NotesUIWorkspace class does not behave in R6 … at least not in any way that I can make sense of. This line would have returned the current ui document in R5, but won’t in R6.

Subject: RE: R6 Bug - NotesUIWorkspace.ComposeDocument

Even if that fails (I’ve heard about that bug, weird), checking that it’s not nothing should deal with that shouldn’t it? (And Vincent does that). The only issue there would be if the NotesUIWorkspace object was not set. Like I say, it’d be a lot easier if he just ran the code through the debugger.

Subject: RE: R6 Bug - NotesUIWorkspace.ComposeDocument

Of course I ran the debugger before posting questions here. As I said, the error, “Object variable is not set,” error was generated by the line – Set newUIDoc = ws.ComposeDocument(…). I am very sure that all variables were set correctly since this has been ran for years with no problems until we upgraded to 6.

By the way, I didn’t mean to ask people to go through the code and fix the problem for me. I post the code so that people can refer to what I was saying in the question (the first paragraph).

Subject: RE: R6 Bug - NotesUIWorkspace.ComposeDocument

It’s funny, but I don’t see where in your original message you say which line the error occurred on, and I don’t see any question.

I’m fairly certain that your problem is not with ComposeDocument per se. The error message means that you’re trying to use an object whose value is Nothing, and so if your problem was with ws.ComposeDocument, implying that ws Is Nothing, then you would also have had a problem with ws.Dialogbox.

I thought perhaps it was targetDB that was Nothing, but in that case you would get an error on the line If Not targetDB.ISOPEN Then

No doubt the error is occurring during the execution of ComposeDocument, but it’s not in the code you’ve shown us. I believe there’s Queryopen or Initialize or Postopen event code on the form you’re composing, and the error occurs in that code. What happens when you compose the form manually, with debug mode on?

Subject: RE: R6 Bug - NotesUIWorkspace.ComposeDocument

Of course I ran the debugger before posting questions here. As I said, the error “Object variable was not set” was generated by the line – Set newUIDoc = ws.ComposeDocument(…)And I am very sure that all variables were set correctly. This code has been ran for years with no problems until we upgrade to 6. By the way, I don’t mean to ask people to go through the code and fix the problem for me. I did that so that people can refer to what I was saying in the question (the first paragraph).

Subject: R6 Bug - NotesUIWorkspace.ComposeDocument

Hi,the problem is in the postopen event of the new doc. In this event, the current document is not the correct current document. Use the “Source”(document) which is in the parameter of the event instead of calling ws.currentdoc. This problem is still in version 6.5.

Bye