A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook - Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Run code once form is sent



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old July 13th 09, 01:32 PM posted to microsoft.public.outlook.program_forms
LDMueller
external usenet poster
 
Posts: 53
Default Run code once form is sent

I created a form in Outlook 2003 with a command button. The code behind the
button is as follows:

Sub cmdScheduleNotification_Click()

dte = FormatDateTime(Item.UserProperties("Laptop Needed Date"), vbShortDate)
tme = FormatDateTime(Item.UserProperties("Laptop Needed Time"), vbShortTime)

Set myItem = Application.CreateItem(1)
myItem.MeetingStatus = 1
myItem.Subject = "Issue Equipment"
myItem.Location = "Equipment is for " & Item.UserProperties("For")
myItem.Start = CDate(dte & " " & tme)
myItem.Duration = 0 'was 90
myItem.ReminderMinutesBeforeStart = 30 '1 day reminder = 1440, 1 week =
10080
myItem.BusyStatus = Free

Set myRequiredAttendee = myItem.Recipients.Add ("LDM")
myRequiredAttendee.Type = 1
Set myOptionalAttendee = myItem.Recipients.Add ("JDE")
myOptionalAttendee.Type = 2
myItem.Send

msgbox "Notification has been Scheduled"

End Sub

This code works fine, however, instead of running the code by pressing the
command button, I'd rather the code run once the user presses "SEND" (after
of course they complete the form).

Can someone help me with this.

Thanks in advance!

LDMueller
  #2  
Old July 13th 09, 02:07 PM posted to microsoft.public.outlook.program_forms
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Run code once form is sent

In the form code window select Script, Event Handler. Add the Send event to
the code.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"LDMueller" wrote in message
...
I created a form in Outlook 2003 with a command button. The code behind
the
button is as follows:

Sub cmdScheduleNotification_Click()

dte = FormatDateTime(Item.UserProperties("Laptop Needed Date"),
vbShortDate)
tme = FormatDateTime(Item.UserProperties("Laptop Needed Time"),
vbShortTime)

Set myItem = Application.CreateItem(1)
myItem.MeetingStatus = 1
myItem.Subject = "Issue Equipment"
myItem.Location = "Equipment is for " & Item.UserProperties("For")
myItem.Start = CDate(dte & " " & tme)
myItem.Duration = 0 'was 90
myItem.ReminderMinutesBeforeStart = 30 '1 day reminder = 1440, 1 week =
10080
myItem.BusyStatus = Free

Set myRequiredAttendee = myItem.Recipients.Add ("LDM")
myRequiredAttendee.Type = 1
Set myOptionalAttendee = myItem.Recipients.Add ("JDE")
myOptionalAttendee.Type = 2
myItem.Send

msgbox "Notification has been Scheduled"

End Sub

This code works fine, however, instead of running the code by pressing the
command button, I'd rather the code run once the user presses "SEND"
(after
of course they complete the form).

Can someone help me with this.

Thanks in advance!

LDMueller


  #3  
Old July 13th 09, 04:03 PM posted to microsoft.public.outlook.program_forms
LDMueller
external usenet poster
 
Posts: 53
Default Run code once form is sent

That was exactly what I needed. I sincerely thank you!

LDMueller

"Ken Slovak - [MVP - Outlook]" wrote:

In the form code window select Script, Event Handler. Add the Send event to
the code.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"LDMueller" wrote in message
...
I created a form in Outlook 2003 with a command button. The code behind
the
button is as follows:

Sub cmdScheduleNotification_Click()

dte = FormatDateTime(Item.UserProperties("Laptop Needed Date"),
vbShortDate)
tme = FormatDateTime(Item.UserProperties("Laptop Needed Time"),
vbShortTime)

Set myItem = Application.CreateItem(1)
myItem.MeetingStatus = 1
myItem.Subject = "Issue Equipment"
myItem.Location = "Equipment is for " & Item.UserProperties("For")
myItem.Start = CDate(dte & " " & tme)
myItem.Duration = 0 'was 90
myItem.ReminderMinutesBeforeStart = 30 '1 day reminder = 1440, 1 week =
10080
myItem.BusyStatus = Free

Set myRequiredAttendee = myItem.Recipients.Add ("LDM")
myRequiredAttendee.Type = 1
Set myOptionalAttendee = myItem.Recipients.Add ("JDE")
myOptionalAttendee.Type = 2
myItem.Send

msgbox "Notification has been Scheduled"

End Sub

This code works fine, however, instead of running the code by pressing the
command button, I'd rather the code run once the user presses "SEND"
(after
of course they complete the form).

Can someone help me with this.

Thanks in advance!

LDMueller



 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Open Appointment form from User Form code and add the attemdee ite masani paresh[_2_] Outlook - Using Forms 2 February 11th 09 11:59 AM
Custom Form Code Joel Allen Outlook and VBA 5 August 15th 07 03:20 AM
VBA Code on Message form to take me to Appointment form LDMueller Outlook and VBA 10 June 14th 07 03:10 PM
How to replace Default Contact form with Customised conact form using VBScript code Satish Boddapati Outlook - Using Contacts 0 October 12th 06 08:20 AM
How to replace Default Contact form with Customised conact form using VBScript code Satish Boddapati Outlook - Installation 0 October 12th 06 08:19 AM


All times are GMT +1. The time now is 07:57 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.