Ich habe das Problem, dass ich in Lotusscript den Namen der Form eines neuen Dokumentes bräuchte. Da das Dokument aber noch nicht gespeichert ist, ist dieser nicht verfügbar. Hier noch mein Code, hoffe jemand hat eine Idee. Geht dabei darum Anhänge einzufügen ohne das Dokument zuvor speichern zu müssen.
Sub Initialize
Dim ws As New NotesUIWorkspace
Dim filenames As Variant
filenames=ws.OpenFileDialog(False,"Bitte Anhang wählen!","Text Dateien|*.txt|Notes Templates|*.ntf","M:\")
If Not(Isempty(filenames)) Then
AddAttachment ws,"fa_Person","ParentUID",filenames(0)
End If
End Sub
Sub AddAttachment(uiws As NotesUIWorkspace, FormName As String,ItemName As String,FileName As String)
Dim uidoc As NotesUIDocument
Dim ws As New NotesUIWorkspace
Dim thisdoc As NotesDocument
Dim rtitem As NotesRichTextItem
Dim olduidoc As NotesUIDocument
Set olduidoc=uiws.CurrentDocument
Set thisdoc = uiws.CurrentDocument.Document ' doc in memory but hasn't been saved yet
thisdoc.RemoveItem ItemName
Set rtitem = New NotesRichTextItem (thisdoc,ItemName)
rtitem.EmbedObject EMBED_ATTACHMENT, "", FileName
rtitem.Update
thisdoc.Form=FormName
' set the SaveOptions field so that when the uidoc is closed, the user won't be asked to save
thisdoc.SaveOptions = "0"
' close the uidoc. It won't actually happen until the code is finished executing
olduidoc.Close False
' create a new uidoc and open the backend doc that is still in memory with added doc link
Set uidoc = uiws.EditDocument(True, thisdoc)
' delete the reference to the old uidoc
' this is necessary because the code below affects it if left in memory
Delete olduidoc
' re-associate the variable with the backend doc
' have to do this because the olduidoc reference was deleted
Set thisdoc = uidoc.Document
' remove the SaveOptions field so the doc can be saved
thisdoc.RemoveItem "SaveOptions"
uidoc.Refresh
End Sub