Hallo Gemeinde,
ich verzweifle gerade an einem Problem.
Ich möchte aus EXcel eine Notesdatenbank öffnen, dort ein neues Dokument anlegen und ein Attachment in ein bestimmtes Feld bringen.
Soweit klappt alles nur den blöden Anhang bekomme ich nicht in mein Feld. Der Anhang wird immer am Ende des Dokuments angezeigt.
Mein RichText Feld hat den Namen "AttachedExcel"
Hier ist mal mein VBA Code:
Sub sSendNotesMail(Subject As String, Attachment As Variant, Recipient As String, BodyText As String, SaveIt As Boolean, Entwurf As Boolean, iErr As Integer)
'Set up the objects required for Automation into lotus notes
Dim db As Object 'The database
Dim UserName As String 'The current users notes name
Dim DbName As String
Dim MainDoc As Object 'The document itself
Dim AttMe As Object 'The attachment richtextfile object
Dim AttachedExcel As Object 'The attachment richtextfile object
Dim Session As Object 'The notes session
Dim EmbedObj As Object 'The embedded object (Attachment)
'Dim Attachment As Variant
iErr = 0
'Start a session to notes
' On Error GoTo ERR1
Set Session = CreateObject("Notes.NotesSession")
UserName = Session.UserName
DbName = "Tems\CancelRequestTP.ntf"
'Open the mail database in notes
Set db = Session.GetDatabase("XKLN1", DbName)
Dim Workspace As Object
Set Workspace = CreateObject("Notes.NotesUIWorkspace")
Call Workspace.OpenDatabase("XKLN1", DbName)
If db.IsOpen = True Then
'Already open
Else
Call Workspace.OpenDatabase("XKLN1", DbName)
End If
Set MainDoc = db.CREATEDOCUMENT
MainDoc.Form = "CancelRequest"
MainDoc.Signature1 = UserName
If Attachment <> "" Then
Set rti = MailDoc.CreateRichTextItem("AttachedExcel")
Set AttachedExcel = rti.EmbedObject(1454, "", Attachment)
End If
On Error GoTo ERR2
Call Workspace.EditDocument(True, MainDoc)
AppActivate "Lotus Notes", True
'Clean Up
Set db = Nothing
Set MainDoc = Nothing
Set AttachME = Nothing
Set Session = Nothing
Set EmbedObj = Nothing
Exit Sub
DAnke für eure Hilfe!!!