Button to add a calendar entry

Hi,

I need help implementing the following code into a button.

Basically, this button add an entry into the recipients calendar.

Error encountered “An operator or semicolon was expected but none was encountered: ‘Click’”

Any pointers is appreciated.

=========================================

Sub Click(Source As Button)

' ############################################################################################

' Attention users:

' Configure this button  via the (Declarations) section, accessed from the Objects tab that should be to the left of this text.

' If you want to get fancy and add rich text in the body, edit the sample code in the AddBody function.

' ############################################################################################



' No user-servicable parts below this line.



' You may notice thiat the following code is tricky. It has to be, because of the following problems with the Notes APIs:

' 1) Textual dates and times are interpreted according to the user's local OS settings when the code runs. 

'     That means you can't use New NotesDateTime with a simple constant string to create a date and time field.

' 2) There's no way to set a NotesDateTime directly to a given time, other than to use a string. You have to go via a

'    LotusScript date/time value.

' 3) LotusScript date/time values have no time zone associated with them, so you can't use them directly to create

'    fields in a document.

' 4) You can only convert a LotusScript date/time to a NotesDateTime in the local time zone of the user, not in UTC.

' 5) @Zone and NotesInternational do not behave as documented. They are described as returning information about

'    whether DST is in effect. In fact, they return whether DST will be in effect at any point during the year, so they're useless.



' Step 1. Work out what time zone the user will be in on the appointment date, including any DST offset.

' First, work out when noon is on the appointment date as a LotusScript date/time.



' this set of variables deal with sending a note to an id you specify when the user presses the button (lets you know they added it)



Dim noon As Variant

noon = Timenumber(EVENT_HOUR, EVENT_MINUTE, 0) + Datenumber(EVENT_YEAR, EVENT_MONTH, EVENT_DAY)

' Then create a NotesDateTime at that local date/time.

Dim startndt As New NotesDateTime("Now")

startndt.LSLocalTime = noon

Dim noongmt As Variant

' Now work out the corresponding GMT time as a LotusScript date/time.

noongmt = startndt.LSGMTTime

Dim tzoffset As Variant

' Subtract the two, multiply by 24 and round to 1 decimal place to get the user's time zone offset from GMT on the specified date.

tzoffset = Round(24 * (noon - noongmt), 1)



' Step 2. Work out a LotusScript date/time for the event.

' First work it out in GMT, using the time zone offset we were given.

Dim lsevent As Variant

lsevent = Timenumber(EVENT_HOUR, EVENT_MINUTE, 0) + Datenumber(EVENT_YEAR, EVENT_MONTH, EVENT_DAY)

lsevent = lsevent - (EVENT_TIME_ZONE / 24)

' Then convert to user's time zone on that date, as computed in step 1.

lsevent = lsevent + (tzoffset / 24)



' Step 3. Convert to a NotesDateTime

startndt.LSLocalTime = lsevent

' Do the same for the end date/time

Dim endndt As New NotesDateTime("Now")

endndt.LSLocalTime = lsevent + (EVENT_DURATION / 24)



' Step 4. Create the appointment document.

' Find user's mail database, open it, create a document.

Dim maildb As New NotesDatabase("", "")

Call maildb.OpenMail

Dim memo As NotesDocument

Set memo = maildb.CreateDocument

'If you want to get feedback from others

sendReply = True	' turns the reply feature on and off - valid values are True and False

replyRecipient = "Rui Kong/China/Contr/IBM"	' who should get the reply - separate multiple recipients with a comma (,)

replySubject = "All Hands 2009 Kick Off Meeting"	' subject of the reply message

replyMessage = "I will be attending."



' Call function to write fields.



calEntrySubject="All Hands 2009 Kick Off Meeting"

Call WriteAppointment(memo, startndt, endndt, EVENT_DESCRIPTION, EVENT_LOCATION, EVENT_ICON)

Call AddBody(memo)

Call memo.Save(True, False, False)

Messagebox "The call has been added to your calendar. Thank you", MB_OK + MB_ICONINFORMATION, "Confirmed"

End Sub

=========================================

Subject: Button to add a calendar entry

Wow, you’re at version 1 of a button tool I wrote a quite a while ago. :slight_smile:

Which line is givng you the error.

My first guess based on the error is it looks like you’re adding the LotusScrpt but have @Functions selected on the drop down menu.

Subject: RE: Button to add a calendar entry

Is it possible to do a similar thing to a hotspot on an image? I know nothing of Notes and need to find a way to do this.