Add a New Appointment in Outlook XP

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Add a New Appointment in Outlook XP

Post by armsys » Tue Feb 18, 2003 12:20 pm

I was astonished by the Emptying Recycle Bin by VBScript thread, which show the powerful capability to create an Excel spreadsheet. It's the holy grail I have been searching for years.

Can someone be very kind enough to show me how to create by Macro Script a new appointment item such that the current date and time is inserted automatically into the Start and End time fields? After filling out other deafult data, the "Untitled - Appointment" window wait for input into the Subject field. How can it be realized by Macro Script plus VBA?

Many thanks in advance.

Lumumba

Post by Lumumba » Tue Feb 18, 2003 4:32 pm

No VB,
sorry ...

//Open new appointment: CTRL+SHIFT+A
Press CTRL
Press SHIFT
Send>A
Release SHIFT
Release CTRL

GetTime>StartTime
GetDate>StartDate

//Start time: ALT+M
Press ALT
Send>M
Release ALT
Send>StartDate
Press Tab
Send>StartTime
Press Tab
//EndDate is set automatically same day / + 1/2 hour

//Subject: ALT+J
Press ALT
Send>J
Release ALT
Send>Meeting with Lumumba to discuss freedom of speech in China

//Close appointment
Press ALT
Send>S
Release ALT

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Post by armsys » Tue Feb 18, 2003 11:10 pm

Hi Lumumba,

Thanks a lot for your painstaking efforts in proposing a Macro script for creating an Appointment in Office XP. I have already done it in Macro script taking into accout all possible worse scenarios when the hot-key is pressed.

Having said that, my desire for a Macro Script/VBA was tempted by another post which shed lights on how to create an Excel spreadsheet by Macro script. By directly instantiating Outlook objects, it will achieve the maximum speed, I suppose.

Regarding the freedom of speech in China, being a visitor of White House, United Nations, and birthplace of George Washington, I'm well versed in the fundamental meaning of human freedom and democracy. How much do you know about China? For this matter, how much do know about the freedom of the States? Read the two books before you judge:
1. A Convenient Spy: Wen Ho Lee and the Politics of Nuclear Espionage
http://www.amazon.com/exec/obidos/tg/de ... ce&s=books
2. My Country Versus Me: The First-Hand Account by the Los Alamos Scientist Who Was Falsely Accused of Being a Spy
http://www.amazon.com/exec/obidos/tg/de ... s&n=507846

Anyway, thanks for your help. Have a nice day.

Lumumba

Post by Lumumba » Wed Feb 19, 2003 7:55 am

Hi Armstrong,
I was sure, if the code won't fit - the "freedom of speech" would be a trigger :wink:. Thx for the links ...

I've found this: (about the AppointmentItem object)

Sub Appointment
Set MyItem = Application.CreateItem(1)
MyItem.Subject = "TestAppointment"
MyItem.StartTime = "12:00"
MyItem.EndTime = "18:00"
MyItem.StartDate = #02/19/03#
MyItem.EndDate = #02/20/03#
MyItem.Save
End Sub

No idea if it works. Don't ask. Can't answer. :oops:

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Wed Feb 19, 2003 10:44 am

Armstrong,

This works:


VBSTART

Sub CreateAppointment (strSubject, strStart, strEnd, strLocation, strMsg)
Set outlookApp = CreateObject("Outlook.Application")
Set oItems = outlookApp.CreateItem(1) 'olAppointmentItem=1
oItems.Subject = strSubject
oItems.Start = strStart
oItems.End = strEnd
oItems.Location = strLocation
oItems.Body = strMsg
'Remove next line to stop appointment appearing on screen
oItems.Display
oItems.Save
'Uncomment next line to close (commented out for demo)
'outlookApp.Quit

'** Other properties available
'** oItems.ReminderSet = TRUE|FALSE
'** oItems.ReminderMinutesBeforeStart = numMins
'** oItems.RequiredAttendees = strAttendees
'** send to recipients
'** oItems.Send

End Sub

VBEND

Let>subject=Meeting with Armstrong
Let>location=Internet
Let>start=02/03/2003 10:00
Let>end=02/03/2003 12:00
Let>msg=Let's discuss Macro Scheduler

VBRun>CreateAppointment,%subject%,%start%,%end%,%location%,%msg%


You may need to change the date format to suit your system. Uncomment the Display and Quit lines if you want to make it completely transparent.



MJT Net Support
[email protected]

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Post by armsys » Wed Feb 19, 2003 12:37 pm

Lumumba & Support,

I'm profoundly grateful for your generosity in offering me the holy grail which I had searched for years. You are my heros. After years everyone told me it's impossible to achieve, you literately create a miracle. At least you shorten my learning curve of integrating both Macro script and VBA.

Lumumba, I'm supremely confident that your China view will be completely changed once you visit Beijing or Shanghai.

Thanks for your big help.

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts