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