pdvsa
asked on
Upload records to Outlook calendar
Hello,
I have a file with hundreds of records.
The file is a list of tasks
with Description, DueDate
10 day reminder notice
I am interested in knowing the vba code to upload this data to Outlook
thank you
I have a file with hundreds of records.
The file is a list of tasks
with Description, DueDate
10 day reminder notice
I am interested in knowing the vba code to upload this data to Outlook
thank you
he following code from mrexcel forum which is going to be placed in as standard module in MS Excel VBE, will delete ALL the task items in MS Outlook and will insert new task items on the active sheet of the MS Excel workbook.
The worksheet which holds the new task items must have the structure as outlined below;
- The labels:
Cell A1 = "Subject"
Cell B1 = "Due Date"
Cell C1 ="Reminding Time"
So, the cells below the label cells should be filled according to these labels.
- Coding:
First of all, in Excel VBE you should add the reference Microsoft Outlook X.0 Library.
Then, copy the code below and paste it to a module in MS Excel VBE then, run the procedure named "Test"
The worksheet which holds the new task items must have the structure as outlined below;
- The labels:
Cell A1 = "Subject"
Cell B1 = "Due Date"
Cell C1 ="Reminding Time"
So, the cells below the label cells should be filled according to these labels.
- Coding:
First of all, in Excel VBE you should add the reference Microsoft Outlook X.0 Library.
Then, copy the code below and paste it to a module in MS Excel VBE then, run the procedure named "Test"
Sub Test()
Dim MyOutlook As Outlook.Application
Dim objTask As TaskItem
Dim NS As NameSpace
Dim NoA As Long, i As Long
NoA = Cells(65536, 1).End(xlUp).Row
Set MyOutlook = New Outlook.Application
Set NS = MyOutlook.GetNamespace("MAPI")
Set MyFolder = NS.Folders("Personal Folders").Folders("Tasks")
Set myItems = MyFolder.Items
'Delete all the items in the "Tasks" folder
For i = MyFolder.Items.Count To 1 Step -1
MyFolder.Items(i).Delete
Next
'Add new items to the "Tasks" folder
For i = 2 To NoA
Set objTask = myItems.Add(olTaskItem)
With objTask
.Subject = Cells(i, 1)
.DueDate = Cells(i, 2)
.ReminderSet = True
.ReminderTime = Cells(i, 3)
.Save
End With
Set objContact = Nothing
Next
Set NS = Nothing
Set MyFolder = Nothing
Set myItems = Nothing
Set MyOutlook = Nothing
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
i agree with Rob. but since the author mentioned being interested to do it the VBA way, i have referred to the VBA.
besides, worth mentioning that David Lee is the most knowledgeable person in outlook VBA i even known. his profile in this forum https://www.experts-exchange.com/members/BlueDevilFan.html
one of the question answered by him that might interest you https://www.experts-exchange.com/questions/23710934/How-to-synchronise-Outlook-Task's-with-a-Excel-Spreadsheet-of-todo-list.html
also a good place to look for vba related to outlook http://www.snb-vba.eu/VBA_Outlook_external_en.html#L91
besides, worth mentioning that David Lee is the most knowledgeable person in outlook VBA i even known. his profile in this forum https://www.experts-exchange.com/members/BlueDevilFan.html
one of the question answered by him that might interest you https://www.experts-exchange.com/questions/23710934/How-to-synchronise-Outlook-Task's-with-a-Excel-Spreadsheet-of-todo-list.html
also a good place to look for vba related to outlook http://www.snb-vba.eu/VBA_Outlook_external_en.html#L91
ASKER
Thank you. I did read, after posting the question, that Outlook does have an import feature.
ASKER