Context: |
Function |
Library/Class: |
Utilities |
Function EmbedFile() As
EmbedFile (Action As String, Note As NotesDocument, Filename As Variant, SaveWithName As Variant, Rtitem As NotesRichtextItem, ReAttach As Integer, SaveDoc As Integer, KillFile As Integer, ShowPBar As Integer) As Integer
This function will embed or attach one or more files to a Notes document. Both, the Notes back-end document as well as the rich text item has to be created previously and passed on to this function.
Parameters:
Either “Attach” or “Embed”. When using the “Embed” option this function will create an embedded object within the passed on rich text item. Only one file can be embedded. The “Attach” option allows creating one or more attachments.
The Notes back-end document the files are to be attached or embedded to.
Names of the file or files to be attached or embedded. The filename(s) have to include the path of the file. The parameter can either be of type String containing a single filename or of type String() or Variant(), containing an array of filenames.
The name or names with which the file(s) are stored in the Notes document (object name). This parameter can be left blank (empty string) in which case the or embedded object or attachments are stored with the physical filename, otherwise it has to correspond with the Filename parameter: if Filename is of type String, this parameter has to be of type String; if the Filename parameter is of type String() then this parameter has to be of type String() and for each element in FileName() one corresponding element in SaveWithName() has to exist.
Rtitem (NotesRichtextItem)
The NotesRichtextItem object in which the file(s) are to be attached or embedded to.
True or False. If True, existing attachments with the same filename or same object name (SaveWithName parameter) will be deleted prior to attaching or embedding the new file(s).
True or False. If True the Notes document will be saved after attaching or embedding the file(s).
True or False. If True, files successfully attached or embedded, will be deleted from the file system.
True or False. If True, this function will display a progress bar.
Return Value:
Integer. True or False.
Sample:
|
Dim doc As NotesDocument
Dim rtitem As NotesRichTextItem
Dim fnam(0) As Variant
Dim savfnam(0) As Variant
Set doc = stats.savdoc
Set rtitem = doc.GetFirstItem(“Attachments”)
If rtitem Is Nothing Then
Set rtitem = doc.CreateRichTextItem(“Attachments”)
End If
fnam(0) = “c:\MyDocument.doc”
savfnam(0) = “”
If EmbedFile(“Attach”,doc,fnam,savfnam,rtitem,False,True,False,False) Then
Call MessageDialog(“File Attached/Embedded Successfully”,0,”Embed File”)
Else
Call MessageDialog(“An error occurred while attaching/embedding the" & _
"file”,0,”Embed File”)
End If
|
|
|