我的Lotus代理会分离文件并将它们放入一个文件夹中 有时,文件具有相同的名称,因此它们被覆盖 我想将文件重命名为,然后将其保存到文件夹
中Set rtitem = curdoc.GetFirstItem( "Body" )
If Not rtitem Is Nothing Then
If Isarray( rtitem.EmbeddedObjects ) Then
Forall o In rtitem.EmbeddedObjects
If ( o.Type = EMBED_ATTACHMENT ) Then
fullpath = path + o.source
Call o.ExtractFile(fullpath)
End If
End Forall
End If
End If
你能告诉我怎么做吗? 非常感谢 最好的祝福 DSEA
答案 0 :(得分:4)
如果您想每次都添加时间,那么您必须"拆分"添加值之前的名称和扩展名中的文件名:
Dim strPath as String
Dim strExtension as String
Dim strFullPath as String
Set rtitem = curdoc.GetFirstItem( "Body" )
If Not rtitem Is Nothing Then
If Isarray( rtitem.EmbeddedObjects ) Then
Forall o In rtitem.EmbeddedObjects
If ( o.Type = EMBED_ATTACHMENT ) Then
fullpath = path + o.source
If Instr( fullpath , "." ) > 0 then
strPath = StrLeftBack( fullpath , "." )
strExtension = "." & StrRightBack( fullpath, "." )
Else
strPath = fullpath
strExtension = ""
End If
strFullPath = strPath & "-" & Format( Now , "yyyymmdd-hhnnss" ) & strExtension
Call o.ExtractFile(strFullPath )
End If
End Forall
End If
End If
当然你可以先"检查"如果文件存在,并且只添加时间值(如果它不是唯一的):
Dim strExist as String
...
If ( o.Type = EMBED_ATTACHMENT ) Then
fullpath = path + o.source
strExist = Dir$( fullPath, 0)
If strExist <> "" then 'exists
If Instr( fullpath , "." ) > 0 then
strPath = StrLeftBack( fullpath , "." )
strExtension = "." & StrRightBack( fullpath, "." )
Else
strPath = fullpath
strExtension = ""
End If
strFullPath = strPath & "-" & Format( Now , "yyyymmdd-hhnnss" ) & strExtension
Else
strFullPath = fullpath
End If
Call o.ExtractFile(strFullPath )
End If