Several people have asked how to use VBA in Excel to call outlook or other office applications.ProgramIn fact, the practice is very simple. The key is to master and use the object model of the target application. Here is an example we have done before: Create a schedule in Excel and then call outlook, add the scheduler to the task becauseCodeI used it at the time, so it was rough.
Excel table:
Code:
Public Sub Writemediutlooktask ()
Dim Task As Outlook. taskitem
Dim RNG As Range
Dim I As Long
For I = 3 To 34 Step 1
If Range ( " B " & I). Value <> "" Then
Set Task = Outlook. application. createitem (oltaskitem)
Task. Subject = " Note: " & Range ( " B " & I). Value & " - " & Range ( " C " & I). Value
Task. startdate = Range ( " A " & I). Value
Task. duedate = Range ( " A " & I). Value
Task. Save
End If
If Range ( " D " & I). Value <> "" Then
Set Task = Outlook. application. createitem (oltaskitem)
Task. Subject = " Review: " & Range ( " B " & I - 2 ). Value & " - " & Range ( " C " & I - 2 ). Value
Task. startdate = Range ( " A " & I). Value
Task. duedate = Range ( " A " & I). Value
Task. Save
End If
If Range ( " E " & I). Value <> "" Then
Set Task = Outlook. application. createitem (oltaskitem)
Task. Subject = " Review: " & Range ( " B " & I - 4 ). Value & " - " & Range ( " C " & I - 4 ). Value
Task. startdate = Range ( " A " & I). Value
Task. duedate = Range ( " A " & I). Value
Task. Save
End If
Next
End sub
Download the complete Excel file: exceloutlook