Reputation: 1
I am trying to insert an attachment file into a Lotus Notes document using VBA. Here is a simplified version of the code I am using:
Dim Anotesuiworkspace as Object
Dim NUIdoc As Object
Dim rtitem As Object
Dim FileName As String
This creates a new Document and opens it on Lotus Notes
Set Anotesuiworkspace = CreateObject("Notes.Notesuiworkspace")
Set NUIdoc = Anotesuiworkspace.composeDocument("", "", "Dash 8 request")
Random File location
FileName = "C:\Users\k0600292\Desktop\Vacation Tracker\Andy Vacation.xlsx"
'$FILE is the name of the Field I am looking to attach the document into
'Get an error while running the next line saying "Object doesnt support this property or method"
Set rtitem = NUIdoc.GetFirstItem("$FILE")
Set object = rtitem.EmbedObject(EMBED_ATTACHMENT, "", FileName)
End Sub
Any recommendations/suggestions will be greatly appreciated.
Upvotes: 0
Views: 1039
Reputation: 2795
1) You do not embed/attach the file into $FILE. You attach it to a Rich-Text field on the form. The field $FILE is a system field.
2) You can only attach files using the back-end classes. EmbedObject() is a method of the NotesDocument class, not of the NotesUIDocument,
Your code should look something like this:
Set doc = uidoc.Document
Set rtitem = doc.GetFirstItem("AttachmentRTField")
Set object = rtitem.EmbedObject(EMBED_ATTACHMENT, "", filename)
Upvotes: 1