PC Review Forums Newsgroups Microsoft Outlook Microsoft Outlook VBA Programming Triggering code when a new all-day event is entered

Reply

Triggering code when a new all-day event is entered

 
Thread Tools Rate Thread
Old 06-11-2004, 06:09 PM   #1
James Martin
Guest
 
Posts: n/a
Default Triggering code when a new all-day event is entered


Hello,

I was hoping someone could help me by telling me how I can get Outlook to
execute code whenever a new all-day event is entered. I've been snooping
around and can't quite figure it out. I've found various articles that say
to:

1. Declare an object variable WithEvents in the ThisOutlookSession module.

2. Initialize the declared object in the Application_Startup procedure.

3. Write code in the ThisOutlookSession module to respond to the declared
object's events.

My problem is with the syntax of each of those things. If it's not too much
trouble could someone provide me with an example of what code I'd actually
have to use for each of those three things in order to fire an event
whenever a new all-day event is entered?

That would be greatly appreciated!

Thanks in advance.

James


  Reply With Quote
Old 07-11-2004, 08:53 AM   #2
Michael Bauer
Guest
 
Posts: n/a
Default Re: Triggering code when a new all-day event is entered

Hi James,

this little sample executes if an Item is added to the default calendar:

'<DieseOutlookSitzung>
Private WithEvents Items As Outlook.Items

Public Sub Application_Startup()
Dim oFld As Outlook.MAPIFolder
Set oFld = Application.Session.GetDefaultFolder(olFolderCalendar)
If Not oFld Is Nothing Then
Set Items = oFld.Items
End If
End Sub

Private Sub Items_ItemAdd(ByVal Item As Object)
Dim oAppt As Outlook.AppointmentItem

If TypeOf Item Is Outlook.AppointmentItem Then
Set oAppt = Item
If oAppt.AllDayEvent Then
' here your code goes
End If
End If
End Sub
'</DieseOutlookSitzung>


--
Viele Grüße
Michael Bauer


"James Martin" <noreply@noreply.com> wrote in message
news:10oq4q3aj8hq823@corp.supernews.com...
> Hello,
>
> I was hoping someone could help me by telling me how I can get Outlook

to
> execute code whenever a new all-day event is entered. I've been

snooping
> around and can't quite figure it out. I've found various articles that

say
> to:
>
> 1. Declare an object variable WithEvents in the ThisOutlookSession

module.
>
> 2. Initialize the declared object in the Application_Startup

procedure.
>
> 3. Write code in the ThisOutlookSession module to respond to the

declared
> object's events.
>
> My problem is with the syntax of each of those things. If it's not too

much
> trouble could someone provide me with an example of what code I'd

actually
> have to use for each of those three things in order to fire an event
> whenever a new all-day event is entered?
>
> That would be greatly appreciated!
>
> Thanks in advance.
>
> James
>
>


  Reply With Quote
Old 08-11-2004, 06:09 AM   #3
James Martin
Guest
 
Posts: n/a
Default Re: Triggering code when a new all-day event is entered

Hi Miachael,

That's perfect!

Thanks a ton for the help. You've saved me hours of frustration!

James



"Michael Bauer" <mib00@t-online.de> wrote in message
news:eaa$agKxEHA.2624@TK2MSFTNGP11.phx.gbl...
> Hi James,
>
> this little sample executes if an Item is added to the default calendar:
>
> '<DieseOutlookSitzung>
> Private WithEvents Items As Outlook.Items
>
> Public Sub Application_Startup()
> Dim oFld As Outlook.MAPIFolder
> Set oFld = Application.Session.GetDefaultFolder(olFolderCalendar)
> If Not oFld Is Nothing Then
> Set Items = oFld.Items
> End If
> End Sub
>
> Private Sub Items_ItemAdd(ByVal Item As Object)
> Dim oAppt As Outlook.AppointmentItem
>
> If TypeOf Item Is Outlook.AppointmentItem Then
> Set oAppt = Item
> If oAppt.AllDayEvent Then
> ' here your code goes
> End If
> End If
> End Sub
> '</DieseOutlookSitzung>
>
>
> --
> Viele Grüße
> Michael Bauer
>
>
> "James Martin" <noreply@noreply.com> wrote in message
> news:10oq4q3aj8hq823@corp.supernews.com...
>> Hello,
>>
>> I was hoping someone could help me by telling me how I can get Outlook

> to
>> execute code whenever a new all-day event is entered. I've been

> snooping
>> around and can't quite figure it out. I've found various articles that

> say
>> to:
>>
>> 1. Declare an object variable WithEvents in the ThisOutlookSession

> module.
>>
>> 2. Initialize the declared object in the Application_Startup

> procedure.
>>
>> 3. Write code in the ThisOutlookSession module to respond to the

> declared
>> object's events.
>>
>> My problem is with the syntax of each of those things. If it's not too

> much
>> trouble could someone provide me with an example of what code I'd

> actually
>> have to use for each of those three things in order to fire an event
>> whenever a new all-day event is entered?
>>
>> That would be greatly appreciated!
>>
>> Thanks in advance.
>>
>> James
>>
>>

>



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off