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