找回密码
 立即注册
搜索
查看: 358|回复: 2

[LotusNotes]小工具: ReplaceField

[复制链接]

19

主题

593

回帖

582

积分

高级会员

积分
582
发表于 2005-6-14 13:56:16 | 显示全部楼层 |阅读模式
自己做的一个小工具, 用来批量修改多个文档的某个域.

用法: 创建一个按钮(Action)
Call ReplaceField

下面是函数库的代码

Function ReplaceField
        ' This Function only work at Client UI
        Dim ws As New NotesUIWorkspace
        Dim uiview As NotesUIView
        Dim dc As NotesDocumentCollection
        Dim doc As NotesDocument
        Dim s As New NotesSession
        Dim db As NotesDatabase
        Dim Fm As NotesForm
        Dim FieldName As String
        Dim OldV As String
        Dim NewV As String
        Redim fields(0)
        Dim F As Variant
       
        Set db=s.CurrentDatabase
        Set uiview=ws.CurrentView
        Set dc=uiview.Documents
        If dc.Count=0 Then
                Msgbox "Please select one document at least."
                Exit Function
        End If
        Set doc=dc.GetFirstDocument
        t=0
        Forall i In doc.Items
                Fields(t)=i.name
                t=t+1
                Redim Preserve Fields(t)
        End Forall
        Redim Preserve Fields(t-1)
        F=Fields
        F=ArraySort(F)
        FieldName=ws.Prompt(4,"Please select Field Name","field name","",F)
        If FieldName="" Then Exit Function
        OldV=Inputbox("Please input Old Value","",doc.GetItemValue(FieldName)(0))
        NewV=Inputbox("Please input New Value","",doc.GetItemValue(FieldName)(0))
        If ws.Prompt(2,"Please Confirm","Are you Sure Replace"+Chr(10)+"Field: "+FieldName+Chr(10)+"Old Value: "+OldV+Chr(10)+"New Value: "+NewV+Chr(10)+"Selected Documents: "+Cstr(dc.Count)) Then
                Set doc=dc.GetFirstDocument
                While Not doc Is Nothing
                        VA=doc.GetItemValue(FieldName)
                        If VA(0)=OldV Then
                                Set item=doc.ReplaceItemValue(FieldName,NewV)
                                Call doc.Save(False,False)
                        End If
                        Set doc=dc.GetNextDocument(doc)
                Wend
        End If
        Call uiview.DeselectAll
End Function

因为LotusR6没有提供ArraySort功能,自己只好做一个.

Function ArraySort(Arr As Variant)
        Dim S As String
        Dim V As Variant
        Dim I As Integer
        Dim J As Integer
       
        V=Arr
        For I=0 To Ubound(V)
                For J=I+1 To Ubound(V)
                        If V(I)>V(J) Then
                                S=V(I)
                                V(I)=V(J)
                                V(J)=S
                        End If
                Next
        Next
        ArraySort=V
       
End Function

19

主题

593

回帖

582

积分

高级会员

积分
582
 楼主| 发表于 2005-7-14 14:10:09 | 显示全部楼层
老兄,这个代码是给Lotus Notes用的。再R6.5下测试通过。R5没有试过,估计可用。
回复

使用道具 举报

45

主题

27

回帖

96

积分

注册会员

积分
96
发表于 2005-7-17 01:12:32 | 显示全部楼层
什么来的,没有看明白
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|海浩社区

GMT+8, 2025-9-17 18:50 , Processed in 0.069254 second(s), 20 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表