Microsoft Office Forums

Go Back   Microsoft Office Forums > Microsoft Office > Outlook

LinkBack Thread Tools Display Modes
Old 05-03-2019, 01:29 PM
jimmynutron jimmynutron is offline Windows 10 Office 2016
Join Date: May 2019
Posts: 2
jimmynutron is on a distinguished road
Default Macro for adding a 15 minute setup meeting before primary meeting with room invite?

I create a meeting in outlook, and add the room as a resource. Outlook then sends the room a meeting invite which it accepts, and that is how we book meeting rooms. I need to add a 15 minute meeting room booking for setups a lot of times. I'm trying to create a macro to do so, but am running into problems. I have it so it pulls everything now, but it will not send the invite. I don't know if its because the macro is for an appointment instead of a meeting, or if there is a way to adjust that etc.? Below is the code I have...

Public Sub Setup()
  Dim coll As VBA.Collection
  Dim obj As Object
  Dim Appt As Outlook.AppointmentItem
  Dim Setup As Outlook.AppointmentItem
  Dim Items As Outlook.Items
  Dim Before&, After&
  Dim Category$, Subject$

  '1. Block minutes before and after the appointment
  Before = 15

  '2. Skip this if the default values never change
  Before = InputBox("Minutes before:", , Before)

  If Before = 0 Then Exit Sub

  '3. Assign this category
  Category = "Setup"

  Set coll = GetCurrentItems
  If coll.Count = 0 Then Exit Sub
  For Each obj In coll
    If TypeOf obj Is Outlook.AppointmentItem Then
      Set Appt = obj
      If TypeOf Appt.Parent Is Outlook.AppointmentItem Then
        Set Items = Appt.Parent.Parent.Items
        Set Items = Appt.Parent.Items
      End If

      '4. Use the main appointment's attribute
      Subject = Appt.Subject
      Location = Appt.Location
      Resources = Appt.Resources

      If Before > 0 Then
        Set Setup = Items.add
        Setup.Subject = Subject + " setup"
        Setup.Location = Location
        Setup.Resources = Resources
        Setup.Start = DateAdd("n", -Before, Appt.Start)
        Setup.Duration = Before
        Setup.Categories = Category
      End If
    End If
End Sub

Private Function GetCurrentItems(Optional IsInspector As Boolean) As VBA.Collection
  Dim coll As VBA.Collection
  Dim Win As Object
  Dim Sel As Outlook.Selection
  Dim obj As Object
  Dim i&

  Set coll = New VBA.Collection
  Set Win = Application.ActiveWindow

  If TypeOf Win Is Outlook.Inspector Then
    IsInspector = True
    coll.add Win.CurrentItem
    IsInspector = False
    Set Sel = Win.Selection
    If Not Sel Is Nothing Then
      For i = 1 To Sel.Count
        coll.add Sel(i)
    End If
  End If
  Set GetCurrentItems = coll
End Function
Reply With Quote
Old 05-06-2019, 09:59 AM
jimmynutron jimmynutron is offline Windows 10 Office 2016
Join Date: May 2019
Posts: 2
jimmynutron is on a distinguished road

Nevermind, I got it to work.
Reply With Quote

Thread Tools
Display Modes

Similar Threads
Thread Thread Starter Forum Replies Last Post
Outlook Meeting Invite Distribution List Attendee updates kdogg121 Outlook 2 06-21-2017 11:58 AM
How to assign a meeting invite to a specific calendar (other than the main/defaut one) Eric B Outlook 0 11-30-2015 10:20 AM
Desktop alert notification doesn't consider the daylight saving in the meeting invite. vara prasad Outlook 0 10-29-2015 06:14 AM
How to delete attendees to a meeting without cancelling meeting PaulaG Outlook 1 11-12-2014 07:08 PM
Adding an invitee to a meeting and sending update does not ask me to send only to new cyndor Outlook 2 10-04-2012 09:04 PM

All times are GMT -7. The time now is 10:05 PM.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc. is not affiliated with Microsoft