请问在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 个回答呵呵呵的回答

呵呵呵呵呵呵软件开发工程师开发
回复 2# clockmaker


    谢谢楼上,不过我是初学者,你说的方法我还不会,上面的代码也是网上找来的。能否帮忙贴下代码,太感谢了!
软件开发 · 2015-08-18
浏览1347

回答者

呵呵呵
软件开发工程师开发

回答状态

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