用lotus script折离文档附件

萧华璋 2012-03-15 01:45:14
Sub creatHtml
Dim session As New notessession
Dim view As notesview
Dim vconview As notesview
Dim doc As notesdocument
Dim rtitem As NotesRichTextItem
Dim path As String
Dim j As Integer
Dim FilePath As String
Dim fileNames As Variant
Dim objEmbed As NotesEmbeddedObject


Dim FileNameqk As String
Dim FileNumqk As Integer

Set db = session.currentdatabase
pathname$=db.filename
Set view = db.getview("ViewPublishedAdmin")
FileNumqk% = Freefile()
FileNameqk$ ="d:\data\zfjr\list.html"

Open FileNameqk$ For Append Access Write As FileNumqk%
Print #FileNumqk%,"12321";
Close FileNumqk%

Kill FileNameqk$

Open FileNameqk$ For Append Access Write As FileNumqk%
Call view.Refresh
Set doc = view.getfirstdocument
Dim numflag As Integer
numflag = 0

While Not doc Is Nothing

If numflag = 0 Then '第一次,开始写文件头
Print #FileNumqk%, "<table width=98% align=center border=0 cellspacing=0 cellpadding=0 class=txt12>"
Print #FileNumqk%,"<tr><td colspan=2 class=box_body>"
numflag = 1
End If

title$ = doc.Title(0)
docId$=doc.DocID(0)
'Set rtitem =doc.GetFirstItem("fBody")
'content$=Cstr(rtitem.text)
fbodystr = Left(doc.fBody,Len(doc.fBody)-1)
fbodystr1 =Cstr(Right(fbodystr,Len(fbodystr)-1))

Print #FileNumqk%,"<a href='";
Print #fileNumqk%, Cstr(docId$)&".html";
Print #FileNumqk%, "' target=_blank ";
Print #filenumqk%, "title=' "
Print #filenumqk%, title$
Print #filenumqk%, "'>";
Print #FileNumqk%, title$;
Print #Filenumqk%,"</a><br>"




'Call tohtml(title$,docId$, fbodystr1,doc)
'printlog(docId$)
FileHtml% = Freefile()
Files$ ="d:\data\zfjr\"+docId$+".html"

Open Files$ For Append Access Write As FileHtml%
Print #FileHtml%,"12321";
Close FileHtml%

Kill Files$

Open Files$ For Append Access Write As FileHtml%

Print #FileHtml%, "<table width='80%' align='center'>"
Print #FileHtml%, "<tr><td align='center' style='font-size:16'>"
Print #FileHtml%, "<b>"+title$+"</b>";
Print #FileHtml%, "</td></tr>"
Print #FileHtml%, "<tr><td>"
Print #FileHtml%, content$+"<br>"

'fileNum=Evaluate("@Attachments",doc)
fileNames=Evaluate("@AttachmentNames",doc)
'files=Cint(fileNum)
'If files>0 Then
If(Isarray(fileNames)<>0) Then
Forall fileName In fileNames
filepath="d:\data\zfjr\fj"
'Print #FileHtml%,fileName
filePath=filePath+"\"+fileName
filepath1="fj/"+fileName
Set objEmbed=doc.GetAttachment(filename)
Print #FileHtml%, "<a href='"+filepath1+"'>"+fileName+"</a><br>"
'Print #FileHtml%,"<a href=>"+filename+"</a>"
Call objEmbed.ExtractFile(filePath)'将文档中的附件导出
Call objEmbed.Remove() '删除文档中的附件
End Forall
' ''
End If
'End If

Print #FileHtml%, "</td></tr>"

Close FileHtml%


'=========================生成==============


Set doc=view.getnextdocument(doc)
Wend

If numflag = 0 Then '文件头未写,补写(此时文件为空)
Print #FileNumqk%, "<table width=98% align=center border=0 cellspacing=0 cellpadding=0 class=txt12>"
End If
Print #FileNumqk%,"</td></tr></table>"

Close FileNumqk%

End Sub

用以上代码实现了有附件的文档的分离,但是如果文档没有附件,报错Object variable not set
...全文
107 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
hanchunyang123 2012-03-15
  • 打赏
  • 举报
回复
如果只有一个域有附件的话,可以@Attachments,获得附件个数,如果为0,则不执行下面的代码。
萧华璋 2012-03-15
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 hanchunyang123 的回复:]

中间加个判断,如果没有附件,则exit sub不可以吗
[/Quote]
你好,请问判断那个参数为空?我加了If(Isarray(fileNames)<>0) Then这个判断但是还是报这个错。
hanchunyang123 2012-03-15
  • 打赏
  • 举报
回复
中间加个判断,如果没有附件,则exit sub不可以吗

535

社区成员

发帖
与我相关
我的任务
社区描述
企业开发 Exchange Server
社区管理员
  • 消息协作社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧