I want to send a Lotus Note with VBA with an Excel file as an attachment. I can do this easily with the code below, (varPath is my path and name) but my task is to attach an Excel file that is created just before the Note is sent, without saving the Excel file in a folder. When the Note is created and sent, the Excel file to be attached is still shown on the screen (will always be named Book1.xlsx by default, I believe). Can this be done WITHOUT first saving the Excel file to a shared folder location? Bottom line: I need to define "attachment1" in the below code as just an Excel Object that is currently open.
Dim objNotes As Object
Dim objNotesDB As Object
Dim objNotesMailDoc As Object
''*******************************
Dim attachment1 As String
Dim AttachME As Object
Dim embedObj1 As Object
''************************************
Set objNotes = GetObject("", "Notes.Notessession")
Set objNotesDB = objNotes.GetDatabase("", "")
Call objNotesDB.OPENMAIL
Set objNotesMailDoc = objNotesDB.CreateDocument
''********************************************************************
attachment1 = varPath
Set AttachME = objNotesMailDoc.CreateRichTextItem("attachment1")
Set embedObj1 = AttachME.EmbedObject(1454, "attachment1", varPath, "")
''**********************************************************************
Call objNotesMailDoc.ReplaceItemValue("SendTo", strRecipient)
Call objNotesMailDoc.ReplaceItemValue("CopyTo", strCCRecipient)
Call objNotesMailDoc.ReplaceItemValue("Subject", strSubj)
Call objNotesMailDoc.ReplaceItemValue("Body", strBody)
Dim objNotes As Object
Dim objNotesDB As Object
Dim objNotesMailDoc As Object
''*******************************
Dim attachment1 As String
Dim AttachME As Object
Dim embedObj1 As Object
''************************************
Set objNotes = GetObject("", "Notes.Notessession")
Set objNotesDB = objNotes.GetDatabase("", "")
Call objNotesDB.OPENMAIL
Set objNotesMailDoc = objNotesDB.CreateDocument
''********************************************************************
attachment1 = varPath
Set AttachME = objNotesMailDoc.CreateRichTextItem("attachment1")
Set embedObj1 = AttachME.EmbedObject(1454, "attachment1", varPath, "")
''**********************************************************************
Call objNotesMailDoc.ReplaceItemValue("SendTo", strRecipient)
Call objNotesMailDoc.ReplaceItemValue("CopyTo", strCCRecipient)
Call objNotesMailDoc.ReplaceItemValue("Subject", strSubj)
Call objNotesMailDoc.ReplaceItemValue("Body", strBody)