火星球长
作者火星球长·2013-01-08 14:55
软件架构设计师·Freewheel

LotusScript样例:将指定视图中所有文档另存为文本

字数 2878阅读 1333评论 1赞 0

%REM

    Agent ExportText

    Created 2012-12-9 by MyLotusTips

    Description: Agent for Export All Fields to Text in Specific View

    使用方法,创建代理,运行时 - 触发器“基于事件”:“操作菜单选择”
    目标“无”
    运行代理即可

%END REM

Option Public

Option Declare


Sub Initialize

    Dim s As New NotesSession

    Dim ws As New NotesUIWorkspace

    Dim db As NotesDatabase

    Dim v As NotesView

    Dim viewNames() As String

    Dim i As Integer

    Dim viewToExport As String

    Dim filename As String

    Dim doc As NotesDocument

    Dim fileNum As Integer

    Set db = s.CurrentDatabase

    ReDim viewNames(0)

    i = 0

    ForAll indView In db.Views

      ReDim Preserve viewNames(i)

      viewNames(i) = indView.Name

      i = i+1

    End ForAll

    viewToExport = ws.Prompt(4, "Choose View", "Choose the view to export from the list below:", "", viewNames)

    If viewToExport = "" Then

        MessageBox ("No view has been selected")

    Exit Sub

    End If

    FileName = InputBox$("Enter the exported file name: ", "LotusScript Export", "C:")

    If (FileName = "") Then

        MessageBox ("Export has been canceled")

        Exit Sub

    End If

 

    Set v = db.GetView(viewToExport)    'Change this to any view you wish, one that includes all documents you wish to export

    Set doc = v.GetFirstDocument

    fileNum = FreeFile()

    Open FileName For Output As fileNum 'Change FileName to the path and filename you wish to create

    'This block loops through every field for every document and sends it to the output file

    Do Until doc Is Nothing

        ForAll j In doc.Items

            Print #fileNum, j.name & ": " & j.text

        End ForAll

    'Adding modified timestamp and breaking line as separator between each document

        Print #fileNum, CStr(doc.initiallymodified)

        Print #fileNum, Chr(12)

        Set doc = v.GetNextDocument(doc)

        On Error Resume Next

    Loop

    Close #fileNum

End Sub

如果觉得我的文章对您有用,请点赞。您的支持将鼓励我继续创作!

0

添加新评论1 条评论

x675412x675412研发工程师失业
2013-01-26 15:17
很好的文章
Ctrl+Enter 发表

作者其他文章

相关问题

相关资料

X社区推广