2014年11月24日 星期一

[AP] 挑選欄位名稱做 remove

Sub Initialize
Dim ws As New NotesUIWorkspace 
Dim session As New NotesSession 
Dim db As NotesDatabase 
Dim dc As NotesDocumentCollection 
Dim doc As NotesDocument
Dim aryFN() As String 
Dim itemField As NotesItem

Set db = session.currentdatabase
Set dc = db.UnprocessedDocuments 
Set doc = dc.getfirstdocument

macro$="@IsNotMember('[ITM OP.]';@UserRoles)"
result=Evaluate(macro$)
If result(0)=1 Then
Beep
Messagebox "您無權限執行本功能!!",,"warning!!"
Exit Sub
End If


If Not doc Is Nothing Then
Redim aryFN(0)
Forall f In doc.Items
'If f.name = "$FILE" Then
If aryFN(0) <> "" Then
Redim Preserve aryFN(0 To Ubound(aryFN)+1)
End If
                        '//aryFN(Ubound(aryFN)) = f.values  取得附檔名稱
aryFN(Ubound(aryFN)) = f.name
'End If
End Forall

varFN = ws.Prompt (PROMPT_OKCANCELLISTMULT,db.Title,"","",aryFN)
If Not Isarray(varFN) Then Exit Sub
Forall m In varFN
                        '//移除附檔
'Set o = doc.GetAttachment (m)
'Call o.remove
Set itemField = doc.GetFirstItem(m)
Call itemField.Remove
Call doc.save(True,False)
End Forall
End If

End Sub

沒有留言:

張貼留言