Solved

VBA create an appointment but wait for user to confirm

Posted on 2008-10-01
5
470 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
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 view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

758 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

19 Experts available now in Live!

Get 1:1 Help Now