您的位置:首页 > 其它

把一个文件夹下面所有txt文件导入notes

2010-03-25 17:19 375 查看
Sub Click(Source As Button)
On Error Goto UnknowError
Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim pathName As String, fileName As String
Dim fileNum As Integer
Dim stream As NotesStream

Set db=session.CurrentDatabase
Set stream = session.CreateStream
directory$ = "D:/Test"
Chdir directory$
fileName$ = Dir$("*.*")
Do While fileName$ <> ""
pathName="D:/Test/" & fileName
If Not stream.Open(pathName) Then
Messagebox fileName$,, "Open failed"
Exit Sub
End If
Set doc = New NotesDocument(db)
doc.Form = "TxtContent"
doc.Txt = stream.ReadText()
Call doc.Save(True,False)
Call stream.Close
fileNum=fileNum+1
fileName$ = Dir$()
Loop
Msgbox "共导入" & fileNum & "个文件"
Exit Sub
UnknowError:
Msgbox "错误行:" & Erl & "错误信息:" & Error
Exit Sub
End Sub
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐