troubleshooting Question

Creating calendar appointment from Excel spreadsheet

Avatar of Carrie Miles
Carrie Miles asked on
Lotus IBMMicrosoft Excel
15 Comments2 Solutions2282 ViewsLast Modified:
I have this partially working, creating a calendar appointment by click a command button in an Excel spreadsheet.  But I keep getting an Object Variable Not Set message on the new appointment in Lotus Notes.

I click the button, it opens the appointment, but the variable message comes up. When I click ok, really quick I can see it's a problem with the duration, it says Incorrect Data and something else.  I can't see what it says because it flashes so quickly and then the appointment closes.

Here is the code I'm using:

Private Sub CommandButton1_Click()
'Set up the objects required for Automation into lotus notes
    Dim Maildb As Object 'The mail database
    Dim MailDbName As String 'The persons notes mail database name
    Dim CalenDoc As Object 'The calendar entry itself
    Dim WorkSpace As Object
    Set WorkSpace = CreateObject("Notes.NOTESUIWORKSPACE")
'Get the engineer username and then calculate the mail file name
    MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) - InStr(1, UserName, " ")))
    MailDbName = "mail\" & Left$(MailDbName, 8) & "user.nsf"
'Create a new calender appointment based on template and set the attributes.
    Set CalenDoc = WorkSpace.COMPOSEDOCUMENT("bbkw1notes", MailDbName, "Appointment")
    CalenDoc.FIELDSETTEXT "AppointmentType", "1"
    CalenDoc.FIELDSETTEXT "StartDate", CStr(Format(Date, "mm/dd/yy"))
    CalenDoc.FIELDSETTEXT "StartTime", CStr(Duration)
    CalenDoc.FIELDSETTEXT "Subject", "Subject"
    CalenDoc.FIELDSETTEXT "Body", "Body"
    CalenDoc.Save False, False, False
    Set Maildb = Nothing
    Set CalenDoc = Nothing
    Set WorkSpace = Nothing

End Sub

Please help!

Thank you
Join our community to see this answer!
Unlock 2 Answers and 15 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 15 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros