Subject: How to attach a document to a Rich Text field?
Hello,
U can attach the Doclink of the document . Using the Picklistcollection, Dialogbox, get the handle of the document and then use AppendDoclink method of NotesRichTextItem class for putting the doclink. U would require to reopen the current document for the changes to take effect.
Subject: RE: How to attach a document to a Rich Text field?
Here is a simple script for that, modify as per ur needs:
Dim session As New NotesSession
Dim workspace As New NotesUIWorkspace
Dim uidoc As notesuidocument
Dim currdoc As notesdocument
Dim db As NotesDatabase
Dim collection As NotesDocumentCollection
Dim doc As NotesDocument
Dim rtf1, rtf2 As notesrichtextitem
Dim rtnav As NotesRichTextNavigator
Dim item,item1 As NotesItem
Dim dbname,dbserver As Variant
Set db = session.CurrentDatabase
Set currdoc = workspace.CurrentDocument.Document
dbname = Evaluate(|@Subset(@Dbname;-1)|,currdoc)
dbserver = Evaluate(|@Subset(@Dbname;1)|,currdoc)
Set collection = workspace.PickListCollection( _
PICKLIST_CUSTOM, _
True, _
Cstr(dbserver(0)), _
Cstr(dbname(0)), _
"(Linked Documents)", _
"Linked Documents", _
"Please select a document." )
If collection.Count = 0 Then
Messagebox "User canceled" ,, _
"No Documents selected to be linked."
Else
Set doc = collection.GetFirstDocument
If currdoc.comprefno(0) <> "" Then
If currdoc.comprefno(0) = doc.comprefno(0) Then
Msgbox "You cannot Link the Documents with same Reference Number. Please try some other document.",0,"Link"
Exit Sub
End If
End If
If currdoc.edrefno(0) <> "" Then
If currdoc.edrefno(0) = doc.edrefno(0) Then
Msgbox "You cannot Link the Documents with same Reference Number. Please try some other document.",0,"Link"
Exit Sub
End If
End If
Set rtf1 = currdoc.GetFirstItem("rtfODL")
If rtf1.type = RICHTEXT Then
While Not ( doc Is Nothing )
If ( rtf1 Is Nothing ) Then
Exit Sub
Else
If doc.comprefNo(0) <> "" Then
Call rtf1.AddNewline(1)
Call rtf1.AppendText("Document : " & doc.comprefNo(0) &" is linked . Please click on the doclink to open the document")
Call rtf1.AppendDocLink(doc,"test")
Else
Call rtf1.AddNewline(1)
Call rtf1.AppendText("Document : " & doc.edrefNo(0) &" is linked . Please click on the doclink to open the document")
Call rtf1.AppendDocLink(doc,"test")
End If
End If
Set doc = collection.GetNextDocument (doc)
Wend
End If
End If
Call currdoc.save(True,True)
currdoc.saveoptions = "0"
Set uidoc = workspace.currentdocument
Call uidoc.Close
Call workspace.editdocument(True,currdoc)
Msgbox "Please save the document using the Save button before linking other documents.",0,"Save Document"
Subject: RE: How to attach a document to a Rich Text field?
Hi,Actually, I want to attach a document WITHOUT opening the current document in EDIT mode. The formula you are suggesting works only if the document is in EDIT mode. Can you help me with this?