Solved

Upload records to Outlook calendar

Posted on 2014-10-09
5
189 Views
Last Modified: 2014-10-10
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
0
Comment
Question by:pdvsa
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 

Author Comment

by:pdvsa
ID: 40371686
I would like the entire list to be uploaded and not record by record.
0
 
LVL 26

Expert Comment

by:ProfessorJimJam
ID: 40372619
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"

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

Open in new window

0
 
LVL 33

Accepted Solution

by:
Rob Henson earned 500 total points
ID: 40372634
Outlook has an import option where you can import a csv file with details for calendar items. The import routine has options for overwriting/creating duplicates etc.

Probably best to use the Export option first to get the column headers etc and then create the csv file with relevant columns.

Thanks
Rob H
0
 
LVL 26

Expert Comment

by:ProfessorJimJam
ID: 40372706
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 http://www.experts-exchange.com/members/BlueDevilFan.html 

one of the question answered by him that might interest you  http://www.experts-exchange.com/Programming/Languages/Visual_Basic/Q_23710934.html


also a good place to look for vba related to outlook  http://www.snb-vba.eu/VBA_Outlook_external_en.html#L91
0
 

Author Closing Comment

by:pdvsa
ID: 40372897
Thank you.  I did read, after posting the question, that Outlook does have an import feature.
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

We are happy to announce a brand new addition to our line of acclaimed email signature management products – CodeTwo Email Signatures for Office 365.
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
In this Experts Exchange video Micro Tutorial, I'm going to show how small business owners who use Google Apps can save money by setting up what is called a catch-all email address in their Gmail accounts. By using the catch-all feature, small busin…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question