Subject: How to display Create Attachment Dialog box using LotusScript
Hi Jian-This will do it:
'paste into declarations
Declare Function NEMGetFile Lib “nnotesws” ( wHandle As Integer, Byval wName As String, Byval wFilter As String, Byval wTitle As String ) As Integer
Sub Click(Source As Button)
On Error Goto End_Routine
Dim s As New NotesSession
Dim db As NotesDatabase
Set db = s.currentdatabase
Dim ui As NotesUIDocument
Dim doc As NotesDocument
Dim rt As NotesRichTextItem
Dim wHandle As Integer
Dim wName As String*256
Dim wTypeList As String
Dim wDlgLabel As String
Dim wReturnedFile As String
Dim ws As New NotesUIWorkspace
Dim MessageText As String
’ Assign parameter values
Set ui = ws.CurrentDocument
Set doc = ui.Document
If doc.HasItem(“Attachments”) Then
Set rt = doc.GetFirstItem(“Attachments”)
Else
Set rt = New NotesRichTextItem(doc, “Attachments”)
End If
wHandle = 0
wName = Left((Trim(s.getEnvironmentString(“Directory”, True))),3)
wTypeList = “All files|.|Acrobat files|.pdf|Word files|.doc|Excel files|.xls|Text files|.txt”
wDlgLabel = “Attach File”
If NEMGetFile( wHandle, wName, wTypeList, wDlgLabel) <> 0 Then
’ Returns 0 if user hits CANCEL
Call ui.Save
unid = doc.UniversalID
wReturnedFile = wName
Call rt.EmbedObject(EMBED_ATTACHMENT, “”, wReturnedFile)
Call doc.Save(True, True, True)
Call ui.Reload
Call ui.Save
Call ui.Close(True) ’ Parameter closes immediately
Set doc = Nothing ’ Clear the variable so Notes will not cache it
Set doc = db.GetDocumentByUNID(unid) ’ Reset the handle
Call ws.EditDocument(True, doc) ’ Reopen the document
End If
End_Routine:
Exit Sub
End Sub