| Sub Click(Source As Button) |
| |
| Dim workspace As New NotesUIWorkspace |
| Dim session As New NotesSession |
| Dim uidoc As NotesUIDocument |
| Dim docB As NotesDocument |
| Dim docStaff As NotesDocument |
| Dim docA As NotesDocument |
| Dim object As NotesEmbeddedObject |
| Dim rtitem As NotesRichTextItem |
| Dim dbB As NotesDatabase |
| Dim dbA As New NotesDatabase ("","") |
| Dim viewID As NotesView |
| Dim collection As NotesDocumentCollection |
| Dim docID As NotesDocument |
| Dim colID As NotesDocumentCollection |
| Dim strFilename As String |
| Dim strID As String |
| |
| Const strDBPath = "xxx\xxx.nsf" |
| |
| On Error Goto ErrorHandler |
| |
| Set dbB = session.CurrentDatabase |
| Set uidoc = workspace.CurrentDocument |
| Set docB = uidoc.Document |
| |
| Call dbA.OpenWithFailover(dbB.Server,strDBPath) |
| |
| If dbA.IsOpen Then |
| |
| Set collection = workspace.PickListCollection( _ |
| PICKLIST_CUSTOM, _ |
| False, _ |
| dbB.Server, _ |
| strDBPath, _ |
| "Viewname", _ |
| "Anhangdokumente", _ |
| "Bitte wählen Sie ein Dokument aus.") |
| If collection.Count = 0 Then |
| Print "User canceled" |
| Exit Sub |
| Else |
| |
| Set docStaff = collection.GetFirstDocument |
| If Not docStaff Is Nothing Then |
| |
| Set viewID = dbA.GetView("(IDs)") |
| |
| strID = docStaff.GetItemValue("ID")(0) |
| |
| |
| Set colID = viewID.GetAllDocumentsByKey(Strleftback(strID,":")) |
| |
| For i = 1 To colID.Count |
| Set docID = colID.GetNthDocument(i) |
| |
| If docID.GetItemValue("Form")(0) = "Profile" Then |
| Set docA = docID |
| End If |
| Next |
| |
| If Not docA Is Nothing Then |
| |
| Call docB.RemoveItem("ProfileAtt") |
| Call CopyItemBE(docB, docA, "Body", "ProfileAtt") |
| |
| End If |
| End If |
| End If |
| End If |
| |
| Call uidoc.Refresh(True,True) |
| Call docB.Save(True, True) |
| |
| Dim unid As String |
| Dim reopendoc As NotesDocument |
| unid = docB.UniversalID |
| |
| Call uidoc.FieldSetText("SaveOptions", "0") |
| Call uidoc.Close |
| |
| Delete docB |
| Delete uidoc |
| |
| Set reopendoc = dbB.GetDocumentByUNID(unid) |
| Set uidoc = workspace.EditDocument(True , reopendoc) |
| |
| Ende: |
| Exit Sub |
| |
| ErrorHandler: |
| Messagebox "Attachments kopieren - Fehler: " & Str$(Err) & " -> '" & Error$ & " in Zeile " & Str$(Erl) , 16, "Fehler" |
| Resume Ende |
| End Sub |