PC Review


Reply
Thread Tools Rating: Thread Rating: 1 votes, 5.00 average.

Create Calendar Appointment with VBScript from Command Button

 
 
Shaun Simma
Guest
Posts: n/a
 
      20th Aug 2003
I have created a customer journal form with several fields on it. I
use the form to keep a chronological journal of projects that I work
on. As I record my journal activity I have a need to create
appointment items to remind me to followup on various journal entries.

On the form is a command button named "CommandButton1" which is not
bound to any control. I have written the following VBScript to execute
when the button is clicked:

Sub CommandButton1_click()
Dim objOL 'As Outlook.Application
Dim objAppt 'As Outlook.AppointmentItem
Const olAppointmentItem = 1
Const olMeeting = 1
Const olFree = 0

Set objOL = CreateObject("Outlook.Application")
Set objAppt = objOL.CreateItem(olAppointmentItem)

objAppt.Subject = "My Test Appointment"
objAppt.Start = #8/19/03 3:50:00 PM#
objAppt.Duration = 1
objAppt.Location = "Followup"
objAppt.Body = "Test Verbiage"
objAppt.ReminderMinutesBeforeStart = 1
objAppt.BusyStatus = olFree
objAppt.Save()
Set objAppt = Nothing
Set objOL = Nothing
End Sub

When I click the command button, an appointment item is automatically
added to my calendar. However, I am having difficulting writing the
script to automatically populate the "Start" and "Body" fields on the
appointment form with data from 2 fields on the journal form.

This is what I have done thus far:

(1) Created a text box on my journal form named "txtFollowUpNotes"
which is bound to a custom control named "FollowUpNotes".

(2) Created a text box on my journal form named "txtFollowUpDate"
which is bound to a custom control named "FollowUpDate" with a
"date/time" type.

I need help with writing/adding the appropriate VBSript code to the
code listed above to automatically populate the "Start Time" on the
appointment field with the date that was entered into the
"txtFollowUpDate" field on the journal form; and to automatically
populate the "Notes" area on the appointment field with the text that
was entered into the "txtFollowUpNotes" field on the journal form.

I have played with this script for two days now trying to
programatically get the data into those fields and have had no luck. I
would appreciate assistance from anyone who can provide me with the
modified script/code needed to accomplish my needs outlined above.

Also, with new journal entries do I have to save the entry before
executing the command button?

Thanks in Advance


Shaun Simma
 
Reply With Quote
 
 
 
 
Shaun Simma
Guest
Posts: n/a
 
      25th Aug 2003
Thanks Ken. Your assistance worked perfectly.

Shaun Simma

"Ken Slovak - [MVP - Outlook]" <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...
> Outlook forms have intrinsic Item and Application objects, so you
> don't need to declare or instantiate your Outlook.Application object.
> Just use Application.
>
> If the fields you mention are properties added to the item or to the
> folder you can use the following code in the Journal form:
>
> Sub CommandButton1_click()
> Dim objAppt 'As Outlook.AppointmentItem
> Const olAppointmentItem = 1
> Const olMeeting = 1
> Const olFree = 0
>
> Set objAppt = Application.CreateItem(olAppointmentItem)
>
> objAppt.Subject = "My Test Appointment"
> objAppt.Start = Item.UserProperties.Item("FollowUpDate")
> objAppt.Duration = 1
> objAppt.Location = "Followup"
> objAppt.Body = Item.UserProperties.Item("FollowUpNotes")
> objAppt.ReminderMinutesBeforeStart = 1
> objAppt.BusyStatus = olFree
> objAppt.Save()
> Set objAppt = Nothing
> Set objOL = Nothing
> End Sub
>
>
> --
> Ken Slovak
> [MVP - Outlook]
> http://www.slovaktech.com
> Lead Author, Professional Outlook 2000 Programming, Wrox Press
> Lead Author, Beginning VB 6 Application Development, Wrox Press
> Attachment Options
> http://www.slovaktech.com/attachmentoptions.htm
> Extended Reminders
> http://www.slovaktech.com/extendedreminders.htm
>
>
> "Shaun Simma" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > I have created a customer journal form with several fields on it. I
> > use the form to keep a chronological journal of projects that I work
> > on. As I record my journal activity I have a need to create
> > appointment items to remind me to followup on various journal

> entries.
> >
> > On the form is a command button named "CommandButton1" which is not
> > bound to any control. I have written the following VBScript to

> execute
> > when the button is clicked:
> >
> > Sub CommandButton1_click()
> > Dim objOL 'As Outlook.Application
> > Dim objAppt 'As Outlook.AppointmentItem
> > Const olAppointmentItem = 1
> > Const olMeeting = 1
> > Const olFree = 0
> >
> > Set objOL = CreateObject("Outlook.Application")
> > Set objAppt = objOL.CreateItem(olAppointmentItem)
> >
> > objAppt.Subject = "My Test Appointment"
> > objAppt.Start = #8/19/03 3:50:00 PM#
> > objAppt.Duration = 1
> > objAppt.Location = "Followup"
> > objAppt.Body = "Test Verbiage"
> > objAppt.ReminderMinutesBeforeStart = 1
> > objAppt.BusyStatus = olFree
> > objAppt.Save()
> > Set objAppt = Nothing
> > Set objOL = Nothing
> > End Sub
> >
> > When I click the command button, an appointment item is

> automatically
> > added to my calendar. However, I am having difficulting writing the
> > script to automatically populate the "Start" and "Body" fields on

> the
> > appointment form with data from 2 fields on the journal form.
> >
> > This is what I have done thus far:
> >
> > (1) Created a text box on my journal form named "txtFollowUpNotes"
> > which is bound to a custom control named "FollowUpNotes".
> >
> > (2) Created a text box on my journal form named "txtFollowUpDate"
> > which is bound to a custom control named "FollowUpDate" with a
> > "date/time" type.
> >
> > I need help with writing/adding the appropriate VBSript code to the
> > code listed above to automatically populate the "Start Time" on the
> > appointment field with the date that was entered into the
> > "txtFollowUpDate" field on the journal form; and to automatically
> > populate the "Notes" area on the appointment field with the text

> that
> > was entered into the "txtFollowUpNotes" field on the journal form.
> >
> > I have played with this script for two days now trying to
> > programatically get the data into those fields and have had no luck.

> I
> > would appreciate assistance from anyone who can provide me with the
> > modified script/code needed to accomplish my needs outlined above.
> >
> > Also, with new journal entries do I have to save the entry before
> > executing the command button?
> >
> > Thanks in Advance
> >
> >
> > Shaun Simma

 
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
How do I hyperlink to create a new calendar appointment? =?Utf-8?B?R2Z1bmM=?= Microsoft Outlook Calendar 0 21st Feb 2007 09:47 PM
How do I create an appointment on a specific calendar =?Utf-8?B?T3NjYXJN?= Microsoft Outlook Calendar 4 31st Jul 2006 09:45 PM
Can't create new calendar appointment. Nothing happens! =?Utf-8?B?S2Vycnk=?= Microsoft Outlook Calendar 3 15th Feb 2006 07:20 PM
Create a button in excel that can open an outlook appointment? =?Utf-8?B?TW92aWVtYW4=?= Microsoft Excel Worksheet Functions 1 15th Jul 2005 01:20 AM
Vbscript from Command Bar Button DaveChoiceTech Microsoft Outlook VBA Programming 2 13th Apr 2005 10:20 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:24 AM.