2nd post- Close currentdoc (or just switch to duplicate doc!)

My script is designed to copy a document, but it won’t ‘close’ the currentdoc (or just switch to duplicate doc would be fine).In addition, now I am getting Object variable not set on the ‘edit document’ line, which was working OK yesterday.

Any ideas? Details below:-

uidoc.close gives the error’variant does not contain an object.

I also tried currentDoc.close(True)

which gives the error

‘Illegal Use of Property’ or

or Call currentDoc.close(True) which gives the error

‘Illegal Use Of Property’

Heres the code again:-

Sub Click(Source As Button)

Dim uiws As New NotesUIWorkspace

Dim session As New NotesSession

Dim currentDB As NotesDatabase

Dim profileView As NotesView

Dim profileDoc As NotesDocument

Dim currentDoc As NotesDocument

Dim duplicateDoc As NotesDocument

Set currentDB = session.CurrentDatabase

Set currentDoc = uiws.CurrentDocument.Document

Set duplicateDoc = New NotesDocument(currentDB)

Call currentDoc.CopyAllItems(duplicateDoc)

Dim eval As Variant

unique = Evaluate(“@Unique”, doc)

Call duplicateDoc.ReplaceItemValue(“OurRef”, unique)

'Call duplicateDoc.ReplaceItemValue(“Stage”, " ")

'Call duplicateDoc.ReplaceItemValue(“ReqCmpDte”, 0)

'Call duplicateDoc.ReplaceItemValue(“Dateneed”, Now + 7)

Call duplicateDoc.Save(True, True)

Dim workspace As NotesUIWorkspace

Call currentDoc.close(True)

'uidoc.Close

Set uiDoc2 = workspace.EditDocument(True, duplicateDoc)

End Sub

Subject: 2nd post- Close currentdoc (or just switch to duplicate doc!)

Currentdoc is a notesdocument, which is in the back-end. There’s no close method for a notesdocument.

Your uidoc.close line won’t work because you haven’t instantiated the uidoc.

Add at the beginning of the script

dim uidoc as notesuidocument

set uidoc = uiws.currentdocument

Then remove the currentdoc.close line and put the uidoc.close line back

That should work I think

Dan

Subject: RE: 2nd post- Close currentdoc (or just switch to duplicate doc!)

Thanks Dan, that works a treat…I needed ‘uidoc1’ as I was using uidoc later to edit the new document.

Heres the code:-

Sub Click(Source As Button)

Dim uiws As New NotesUIWorkspace

Dim session As New NotesSession

Dim currentDB As NotesDatabase

Dim profileView As NotesView

Dim profileDoc As NotesDocument

Dim currentDoc As NotesDocument

Dim duplicateDoc As NotesDocument



Set currentDB = session.CurrentDatabase



Set currentDoc = uiws.CurrentDocument.Document

Set duplicateDoc = New NotesDocument(currentDB)

Call currentDoc.CopyAllItems(duplicateDoc)

Dim eval As Variant

unique = Evaluate("@Unique", doc)

Call duplicateDoc.ReplaceItemValue("OurRef", unique)

'Call duplicateDoc.ReplaceItemValue("Stage", " ")

'Call duplicateDoc.ReplaceItemValue("ReqCmpDte", 0)

'Call duplicateDoc.ReplaceItemValue("Dateneed", Now + 7)

Call duplicateDoc.Save(True, True)

Dim uidoc1 As notesuidocument

Set uidoc1 = uiws.currentdocument

uidoc1.Close

Dim uidoc As NotesUIDocument

Set uiDoc = uiws.EditDocument(True, duplicateDoc)

End Sub