毎回時間を追加したい場合は、値を追加する前に、名前と拡張子でファイル名を「分割」する必要があります。
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
もちろん、最初にファイルが存在するかどうかを「確認」し、一意でない場合にのみ time- 値を追加できます。
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