Hi David,
He only tracks them... There should be no editing really. I think
that there is a way to do this, because he informed me that he had an
Access database linked to his tasks in Outlook previously, but that
database is now retired somewhere and I don't know where it is... He
would use the "milage" field in the "details" tab of the task to state
who the task came from and stuff like that...
I just wrote some procedures to do just the same thing you want to do.
If you put the following code into a standard module and start
"AufgabenExportieren" (it's in German, so you have to translate some
function names and so on ...).
This will export all tasks saved in a table named "tblAufgaben" to
Outlook's standard task folder.
You might have to customize the table and field names in the code -
there are just a few sample properties of a task. You also have to add a
line to export your name/id to the milage field.
The procedure uses the billinginformation field to save the id (primary
key) of the task in your task table in the Outlook task. So it is able
to check whether the task is already there (and to be updated) or not -
in this case the procedure adds a new task.
Dim mOutlook As Outlook.Application
Dim mMAPINamespace As Outlook.NameSpace
Dim mTaskFolder As Outlook.Folder
Public Property Get GetOutlook() As Outlook.Application
If mOutlook Is Nothing Then
On Error Resume Next
Set mOutlook = CreateObject("Outlook.Application")
If Err.Number = 429 Then
MsgBox "Outlook konnte nicht gestartet werden."
Exit Property
End If
End If
Set GetOutlook = mOutlook
End Property
Public Property Get GetMAPINamespace() As Outlook.NameSpace
If mMAPINamespace Is Nothing Then
Set mMAPINamespace = GetOutlook.GetNamespace("MAPI")
End If
Set GetMAPINamespace = mMAPINamespace
End Property
Public Property Get GetTaskFolder() As Outlook.Folder
If mTaskFolder Is Nothing Then
Set mTaskFolder = GetMAPINamespace.GetDefaultFolder(olFolderTasks)
End If
Set GetTaskFolder = mTaskFolder
End Property
'--> start this sub to export tasts from a table to Outlook
Public Sub AufgabenExportieren()
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim objTaskItem As Outlook.TaskItem
Set db = CurrentDb
Set rst = db.OpenRecordset("tblAufgaben", dbOpenDynaset)
Do While Not rst.EOF
If Not AufgabeNachID(rst!ID, objTaskItem) = True Then
Set objTaskItem = GetTaskFolder.Items.Add
End If
With objTaskItem
.BillingInformation = rst!ID
.Subject = rst!Subject
.Body = rst!Body
.StartDate = rst!StartDate
.DueDate = rst!DueDate
.DateCompleted = rst!DateCompleted
.PercentComplete = rst!PercentComplete
.Importance = rst!Importance
.Save
End With
rst.MoveNext
Loop
End Sub
Public Function AufgabeNachID(lngID As Long, objAufgabe As
Outlook.TaskItem) As Boolean
Dim objTaskItem As Outlook.TaskItem
Set objTaskItem = GetTaskFolder.Items.Find("[BillingInformation] =
" & lngID)
If Not objTaskItem Is Nothing Then
Set objAufgabe = objTaskItem
AufgabeNachID = True
End If
End Function
Bye
André