Skapa en uppgift


Här demonstreras ett förfaringssätt för att hämta uppgifter från Excel och skapa en uppgift i Outlook. Tipset kan relativt enkelt utvecklas för att skapa flera uppgifter på en gång.

För att exemplet ska fungera krävs att en referens till MS Outlook x.x objektbibliotek anges.

 

Om ett felmeddelande erhålls vid kopiering till VBA-modul så läs mer här»
 

 

(© 2002 - 2003 All rights Colo - Used by permission)

 Option Explicit

Sub Skapa_Uppgift()

   '© 2003 Alla rättigheter XL-Dennis

   Dim olApp As Outlook.Application

   Dim olTask As Outlook.TaskItem

 

   Set olApp = New Outlook.Application

   Set olTask = olApp.CreateItem(3)

 

   Application.ScreenUpdating = False

 

   With olTask

      .Subject = "Projekt VB:" & Cells(2, 1).Value

      .Body = Cells(2, 3).Value

      .StartDate = Cells(2, 4).Value

      .DueDate = Cells(2, 5).Value

      .Status = olTaskWaiting

      .Importance = olImportanceHigh

      .ReminderPlaySound = True

      .Companies = "XL-Dennis"

      .Save

   End With

 

   Set olTask = Nothing

 

   Set olApp = Nothing

 

   Application.ScreenUpdating = True

 

   MsgBox "Uppgiften har skapats!", vbInformation

 

End Sub