PC Review


Reply
Thread Tools Rate Thread

Triggering code when a new all-day event is entered

 
 
James Martin
Guest
Posts: n/a
 
      6th Nov 2004
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
 
 
 
 
Michael Bauer
Guest
Posts: n/a
 
      7th Nov 2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
 
James Martin
Guest
Posts: n/a
 
      8th Nov 2004
Hi Miachael,

That's perfect!

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

James



"Michael Bauer" <(E-Mail Removed)> wrote in message
news:eaa$(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> 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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Combo Box Event code self triggering?? Sam Microsoft Excel Programming 0 13th Aug 2008 06:10 PM
Event's code runs to completion before another event's code is entered? Academia Microsoft VB .NET 8 1st Nov 2007 08:13 PM
onMouseOver event is triggering the parent element's code Nathan Sokalski Windows XP Internet Explorer 1 19th Jun 2006 08:50 PM
Doing a javascript form.submit and triggering server side event code for button John Boy Microsoft ASP .NET 4 9th Nov 2005 12:25 PM
Re: Triggering an event Woody Splawn Microsoft VB .NET 1 25th Aug 2003 08:02 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:12 PM.