请问在Lotus notes中,如何批量保存文档中多个文本域中的附件

我用了以下的代码可以批量保存多个文档中一个文本域的附件,比如htwj,如果要保存多个文本域的附件,比如htwj_1和htwj_2,该如何写呢。请大神指点,谢谢!Sub Initialize()Dim session As New NotesSessionDim db As NotesDatabaseDim collection As NotesDocumentCollectionDim doc...显示全部
我用了以下的代码可以批量保存多个文档中一个文本域的附件,比如htwj,如果要保存多个文本域的附件,比如htwj_1和htwj_2,该如何写呢。请大神指点,谢谢!

Sub Initialize()

Dim session As New NotesSession
Dim db As NotesDatabase
Dim collection As NotesDocumentCollection
Dim doc As NotesDocument   
Dim rtitem As Variant
Dim s As Variant  
Dim NotesItem As NotesItem

Dim bi As BROWSEINFO
Dim pidl As Long
Dim path As String
Dim pos As Integer

'Fill the BROWSEINFO structure with the
'needed data. To accomodate comments, the
'With/End With sytax has not been used, though
'it should be your 'final' version.

'hwnd of the window that receives messages
'from the call. Can be your application
'or the handle from GetDesktopWindow().
bi.hOwner = GetDesktopWindow()

'Pointer to the item identifier list specifying
'the location of the "root" folder to browse from.
'If NULL, the desktop folder is used.
bi.pidlRoot = 0&

'message to be displayed in the Browse dialog
bi.lpszTitle = "Select your Directory"

'the type of folder to return.
bi.ulFlags = BIF_RETURNONLYFSDIRS

'show the browse for folders dialog
pidl = SHBrowseForFolder(bi)

'the dialog has closed, so parse & display the
'user's returned folder selection contained in pidl
path = Space$(MAX_PATH)

If SHGetPathFromIDList(Byval pidl, Byval path) Then
pos = Instr(path, Chr$(0))
End If

Call CoTaskMemFree(pidl)

Set db = session.CurrentDatabase
Set collection = db.UnprocessedDocuments
Set doc = collection.GetFirstDocument()

While Not(doc Is Nothing)         
Set rtitem = doc.GetFirstItem( "htwj" )  '附件字段域名为htwj
If ( rtitem.Type = RICHTEXT ) Then
Forall o In rtitem.EmbeddedObjects     
If ( o.Type = EMBED_ATTACHMENT ) Then
Call o.ExtractFile( Left(path, pos - 1) & "" & o.Name  )
End If
End Forall
End If

Set doc = collection.GetNextDocument(doc)
Wend

End Sub收起
参与8

查看其它 1 个回答clockmaker的回答

clockmakerclockmaker项目经理
把域名放到数组里,做个循环不就完了。
软件开发 · 2015-08-18
浏览1512

回答者

clockmaker
项目经理
擅长领域: 系统管理服务器java

clockmaker 最近回答过的问题

回答状态

  • 发布时间:2015-08-18
  • 关注会员:1 人
  • 回答浏览:1512
  • X社区推广