Re: Tasks and Calendar
From: Michael Bauer (mib00_at_t-online.de)
Date: 01/10/05
- Previous message: Sue Mosher [MVP-Outlook]: "Re: OLK2K3: Programmatically setting checkboxes in printout to tem"
- In reply to: D: "Re: Tasks and Calendar"
- Next in thread: Thomas Wetzel: "Re: Tasks and Calendar"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 10 Jan 2005 21:47:16 +0100
In code you will need to declare a variable, which can be a type of
AppointmentItem, e.g.:
' Declare the variable.
Dim oAppt as Outlook.AppointmentItem
' The function creates a new object and returns it´s reference, which
you _
have to store in the variable.
Set oAppt=Application.CreateItem(olAppointmentItem)
The event you are looking for is the ItemAdd event:
Private WithEvents m_CalendarItems as Outlook.Items
Private Sub Application_Startup()
Set m_CalendarItems = _
Application.Session.GetdefaultFolder(olFodlerCalendar).Items
End Sub
In the head of your code window are two comboboxes: select from the left
one the variable, you´ve declared (CalendarItems), then select from the
right one the event you want to receive: ItemAdd. The event procedure
now will be created for you automatically.
(Note in addition: You also should handle the case the function runs
more than once. It should be avoided that the same task will be written
twice into the calendar.)
-- Viele Grüße Michael Bauer "D" <valdezdj@fotf.org> wrote in message news:A1DFE5C2-C055-4C09-9EC3-085E7CAF0A30@microsoft.com... > I'm a bit confused on the AppointmentItem.Start because when I insert this in > it gives me an object must be defined error and I cannot find or place an > object that goes there. I took your advice and I think that c is the best > choice for the user but can we do a function or event that when she inputs a > task it automatically goes to the Calendar? Thanks for your help. > D > > "Michael Bauer" wrote: > > > Well, if you think, coding that is easier, let´s start :-) > > > > In which manner should the items be selected? You could: > > a) select them by mouse, > > b) get items by searching for keywords like category or subject (or any > > other), > > c) handle all folder items. > > > > Ad a) The selection is available via the > > Application.ActiveExplorer.Selection collection which you can loop > > through. > > > > Ad b) The most properties you can look for with the > > Application.ActiveExplorer.CurrentFolder.Items.Restrict function. The > > function returns an Items collection which you can loop through. Please > > select the Restrict method in the object browser (F2) and press F1 for > > help. The syntax for the filter is explained and also the properties you > > can´t use. In this cases you need to loop through all folder items and > > check item by item for the keywords. > > > > ad c) Loop through the Application.ActiveExplorer.CurrentFolder.Items > > collection and handle all items. > > > > Sample for a loop through a collection: > > > > Dim AnyObj as Object > > Dim AnyCollection As Outlook.Items ' (for b, c) or: As Outlook.Selection > > (for a) > > Dim oTask As Outlook.TaskItem > > > > ' ad a) > > Set AnyCollection = Application.ActiveExplorer.Selection > > > > For Each AnyObj in AnyCollection > > ' check the type of AnyObj > > If TypeOf AnyObj Is Outlook.TaskItem Then > > Set oTask = AnyObj > > ' Handle the TaskItem. Using oTask instead of AnyObj is faster > > and _ > > you can benefit from IntelliSense > > Endif > > Next > > > > A new item you can create with Application.CreateItem. If you´ve created > > a new AppointmentItem then you can fill it´s properties with some values > > from your TaskItem, e.g.: > > AppointmentItem.Start = TaskItem.StartDate > > > > After you´ve finished, just call AppointmentItem.Save for storing the > > new data permanently. > > > > Ok, now you´ve got some examples and keywords for your search in the > > object browser (the beginner´s best friend). Please post again if you > > have any more question. > > > > -- > > Viele Grüße > > Michael Bauer > > > > > > "D" <valdezdj@fotf.org> wrote in message > > news:89DBB905-1484-409D-8AE2-DE1966DEAD93@microsoft.com... > > > Thank you. But is there a way that they can automatically go the > > correct > > > date, w/ VBA. I gave them the solution but (you know users) she would > > like an > > > easier way, because she has over 300 tasks. > > > > > > "Michael Bauer" wrote: > > > > > > > Just drag the items with the right mouse button to the calendar, > > then > > > > select the proper command from the popup menu. > > > > > > > > -- > > > > Viele Grüße > > > > Michael Bauer > > > > > > > > > > > > "D" <valdezdj@fotf.org> wrote in message > > > > news:26368605-9CBC-41C0-B816-0C2668BDE384@microsoft.com... > > > > > This is a good bear with me. > > > > > I have a user that has many tasks created(over 300) and he would > > like > > > > to put > > > > > them in the calendar. The tasks have dates and he would like the > > tasks > > > > to be > > > > > put in the calendar according to their dates. Help me please! > > > > > Thanks, > > > > > -- > > > > > D > > > > > > > > > > > >
- Previous message: Sue Mosher [MVP-Outlook]: "Re: OLK2K3: Programmatically setting checkboxes in printout to tem"
- In reply to: D: "Re: Tasks and Calendar"
- Next in thread: Thomas Wetzel: "Re: Tasks and Calendar"
- Messages sorted by: [ date ] [ thread ]