高分请教:B/S下用LotusScript如何实现从一份文档拷贝多个附件到另一份文档

rugl 2003-11-13 04:53:38
找了好多地方,都找不到完善的解决办法,请大家帮忙了。

我用了下面的方法(这也是从论坛上找到的),结果只能拷贝第一个附件,并且拷贝过去的附件打开时出错,根本打不开(无论是word文档还是图片都一样),在删除这份文档的时候,会报如下错误:一个或者多个源文档的附加文件被丢失,运行“Fixup”删除源数据库中的文档。

Set Item = doc.GetFirstItem( "$File" )
Set Doc_Tmp = New NotesDocument(DB)
Doc_Tmp.Form="CopyFile"
Set ItemA = Doc_Tmp.GetFirstItem("$FILE"
Call Doc_Tmp.ReplaceItemValue("$File",doc.GetFirstItem( "$File" ))
Call Doc_Tmp.Save(True,True)

用下面这种方法轮询,也只能取到一个,并且拷贝过去的附件也和前面的一样出错

If doc.HasItem("$File" Then
For i=0 To 50 '最多50个附件
Set item = doc.Items(i)
if item.name="$file" then
cal doc1.appendItemValue("$file",item)
end if
next
end if

请教这个问题有什么好方法可以解决,多谢了!
...全文
116 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
icecoldy 2003-11-21
  • 打赏
  • 举报
回复
不是很懂,学习中:)
YuLimin 2003-11-21
  • 打赏
  • 举报
回复
我有一个最简单,可能也是最笨的方法

拷贝那个文档,然后删除不要的域

Set docTemp = dbTemp.CreateDocument
Call docMail.CopyAllItems(docTemp,True)
Forall item In docTemp.Items
strItemName = Ucase(item.Name)
If strItemName <> "$FILE" And strItemName <> "BODY" And strItemName <> "WBODY" Then
item.Remove
End If
End Forall

Call docTemp.ReplaceItemValue("UNID",docMail.UniversalID)
Call docTemp.ReplaceItemValue("Form","YourForm")

Call docTemp.Save(False,True)
fengyi999 2003-11-21
  • 打赏
  • 举报
回复
光拷贝$File是没有用处的,只是拷贝连接而已!如果原文档删除,附件照样也没有了!

http://expert.csdn.net/Expert/topic/2220/2220014.xml?temp=.3890039
参考该贴!
xinzp 2003-11-21
  • 打赏
  • 举报
回复
问题出在下面这句:
Call Doc_Tmp.ReplaceItemValue("$File",doc.GetFirstItem( "$File" ))

ReplaceItemValue()是替换
AppendItemValue()是添加
替换相当于熊瞎子擗苞米,最后只剩一穗:)
ntko 2003-11-14
  • 打赏
  • 举报
回复
Set doc = ........... (the source doc)
Set doc1 = ......... (the target doc)

Forall x In doc.items

cc = x.Values(0) ' The name of the attachment
fileloc = "C:\"+cc

' Copy the attchment to disk
Set object = doc.GetAttachment( cc )
Call object.ExtractFile( "C:\"+cc )

' Now upload the attachment to the other doc
Set rtItem = doc1.GetFirstItem("Attachments")
If (rtItem Is Nothing) Then
Set rtItem = doc1.CreateRichTextItem("Attachments")
End If
Call rtItem.embedobject (EMBED_ATTACHMENT,"", fileloc, cc )
Call doc1.Save( True, True )

' Delete the detached attachment from disk
Kill fileloc
fengyi999 2003-11-14
  • 打赏
  • 举报
回复
http://expert.csdn.net/Expert/topic/2220/2220014.xml?temp=.3890039
参考该贴!
temcozw 2003-11-13
  • 打赏
  • 举报
回复
Set rtitem=newdoc.CreateRichTextItem("FuJian")
加个判断
if newdoc.hasitem("FuJian") then
set rtitem=newdoc.getfirstitem("FuJian")
else
Set rtitem=newdoc.CreateRichTextItem("FuJian")
end if
temcozw 2003-11-13
  • 打赏
  • 举报
回复
If note.HasEmbedded Then
LvarEmbObj = Evaluate("@AttachmentNames",note)
For i=0 To Ubound(LvarEmbObj)
Set obj=note.GetAttachment(LvarEmbObj(i))
If ( obj.Type = EMBED_ATTACHMENT ) Then
Call obj.ExtractFile(path$ & attName )
Set rtitem=newdoc.CreateRichTextItem("FuJian")
Call rtitem.EmbedObject( EMBED_ATTACHMENT, "", path$ & attName)
end if
next
End If

你试试

535

社区成员

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

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