Solved

VBA create an appointment but wait for user to confirm

Posted on 2008-10-01
5
473 Views
Last Modified: 2013-12-26
i,

I am using the following code from the MC website to create an appointment from VBA under Excel:

 ' Create a new appointment.
   Dim olAppt As Outlook.AppointmentItem
   Set olAppt = olApp.CreateItem(olAppointmentItem)
   
 ' Set start time for 2-minutes from now...
   olAppt.Start = Now() + (2# / 24# / 60#)
   
 ' Setup other appointment information...
   With olAppt
      .Duration = 60
      .Subject = "Meeting to discuss plans..."
      .Body = "Meeting with " & olItem.FullName & " to discuss plans."
      .Location = "Home Office"
      .ReminderMinutesBeforeStart = 1
      .ReminderSet = True
   End With
   
 ' Save Appointment...
   olAppt.Save

It all works fine. However, it would be really handy if I could create the appointment and display it to the user - who would then confirm the save, and make changes to the appointment if required.

Is there a way to do this?

Cheers

Bergsy
0
Comment
Question by:gbergsma
  • 3
  • 2
5 Comments
 
LVL 17

Expert Comment

by:wobbled
ID: 22612697
There are two ways you can do this.  You can create the appointment as you do and then follow it with do you wish to confirm Yes / No.  If they click No you would then have to delete the appointment.  This is not a very good approach as you are creating the appointment then deleting it.

What I would recommend is that you just populate a userform etc with the information regarding the appointment.  Only then if they click Yes do you actually call your code above and create the appointment.
0
 

Author Comment

by:gbergsma
ID: 22612734
Unfortunately that doesnt give me the function I am looking for. I would like the user toi be able to interact with the Outlook appointment and make any changes (invite others, recurrence and so on) rather than having to build all of that with my own forms
0
 
LVL 17

Accepted Solution

by:
wobbled earned 125 total points
ID: 22612769
OK - I don't have outlook installed on my PC but can you not just add the line .display = true

With olAppt
      .Duration = 60
      .Subject = "Meeting to discuss plans..."
      .Body = "Meeting with " & olItem.FullName & " to discuss plans."
      .Location = "Home Office"
      .ReminderMinutesBeforeStart = 1
      .ReminderSet = True
      .Display = True
   End With
   
0
 

Author Closing Comment

by:gbergsma
ID: 31501892
.Display did it (without the "= True"
0
 
LVL 17

Expert Comment

by:wobbled
ID: 22613545
Great glad to have helped
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now