AW: Outlook Task mit VBA automatisieren
29.01.2015 11:25:39
Allan
Hallo Klaus
Danke für deine Antwort und deinen Rat betreffend Name. Hier mein gesamter Code und Denkansatz:
Sub Schaltfläche4_Klicken()
UserForm1.Show
End Sub
Function GetTaskActions(NewTask As Outlook.TaskItem) As Outlook.Actions
Set GetTaskActions = NewTask.Actions
End Function
Sub Mail_to_PM_with_Outlook()
Dim objOLApp As Outlook.Application
Dim NewTask As Outlook.TaskItem
Dim Acts As Outlook.Actions
Dim myDelegate As Outlook.Recipient
Dim Editor As String
Editor = Range("J6").End(xlDown).Value
Dim Process_OLD As Variant
Process_OLD = Range("B6").End(xlDown).Value
Dim Process_NEW As Variant
Process_NEW = Range("C6").End(xlDown).Value
Dim Status As String
Status = Range("K6").End(xlDown).Value
Set objOLApp = CreateObject("Outlook.Application")
Set NewTask = objOLApp.CreateItemFromTemplate("[Template_Path]\Aufgabenvorlage.oft")
Set myDelegate = NewTask.Recipients.Add("user@domain") 'Empfänger E-Mail
Set Acts = GetTaskActions(NewTask)
'Send to Outlook Task Form
NewTask.StartDate = Now()
NewTask.Status = olTaskInProgress
NewTask.DueDate = Format(Now() + 3, "dd.mm.yyyy")
NewTask.Assign = Editor & ", " & Process_OLD & " / " & Process_NEW & " / " & Status
NewTask.Display
MsgBox "Prozess erfolgreich übertragen"
End Sub
'Der obengenannte Code funktioniert prima für die letzte Zeile in der Tabelle.. Ich möchte jetzt aber bewirken, dass
wenn ich auf Zelle D3 bin und mein Skript per Button auslöse, dass dann jeweils den Wert von der Zelle A3 + B3 + C3 verkettet
wird und dann im Titel-feld der Outlook-Task-Form gezogen wird. Siehe unten mein Denkansatz von heute Morgen.
Sub Zeilenbestimmung()
Dim i As Variant
Dim k As Long
Dim ID As String
ID = Cells(i, 1).Value
Dim Nr_OLD As Integer
Nr_OLD = Cells(i, 2).Value
Dim Nr_NEW As Integer
Nr_NEW = Cells(i, 3).Value
i = ActiveCell.Value
If Columns(i, 3) = ActiveCell.Select Then
Cells(i, "1:3").Value 'Hier habe ich Mühe den Syntax nachzuvollziehen
End If
'Outlook Assignment
NewTask.Assign = ID & ", " & Nr_NEW & " / " & Nr_OLD
End Sub