VBA to create meeting from template from a time slot selected in someone's calendar

Status
Not open for further replies.

AlexP

New Member
Outlook version
Outlook 2013 32 bit
Email Account
Outlook.com (as MS Exchange)
Hello Diane and all fellow forum members :)

For the last a few days I was struggling to write a VBA code that does very simple thing: assume I open ANY calendar available to me (either my calendar or any shared calendar), then I select a time slot I want schedule meeting at, then run a macro that creates a meeting with selected time. The code works fine if I select a time slot in my calendar, and it also picks correct time in a shared calendar - the only thing I can't figure out is how to get email address of the shared calendar (so I can add an attendee with this email address).

The code I've got at the moment is the following:
Code:
Sub TestSub()
Const datNull As Date = #1/1/4501#
Dim myItem As Object
Dim myRequiredAttendee, myOptionalAttendee, myResourceAttendee As Outlook.Recipient
Dim datStart As Date
Dim datEnd As Date
Dim oView As Outlook.View
Dim oCalView As Outlook.CalendarView
Dim oExpl As Outlook.Explorer
Dim oFolder As Outlook.Folder
 Set oExpl = Application.ActiveExplorer
 Set oFolder = Application.ActiveExplorer.CurrentFolder
 Set oView = oExpl.CurrentView
' Check whether the active explorer is displaying a calendar view.
 If oView.ViewType = olCalendarView Then
  Set oCalView = oExpl.CurrentView
  ' Create the appointment using the values in
  ' the SelectedStartTime and SelectedEndTime properties as
  ' appointment start and end times.
  datStart = oCalView.SelectedStartTime
  datEnd = oCalView.SelectedEndTime
Dim myTemplate As String
myTemplate = "<path to template>\templatename.oft"
Set myItem = Application.CreateItemFromTemplate(myTemplate)

  Dim strCategories As String
  Dim strSubject As String
  strCategories = "MyColourCategory"
  strSubject = "Change subject line"
  Set myRequiredAttendee = myItem.Recipients.Add("name.surename@outlook.com")
 
With myItem
  .Subject = strSubject
  .Categories = strCategories
  .ReminderSet = bolRemindMe
  .Body = strBody
  If bolRemindMe = True Then
  .ReminderMinutesBeforeStart = intRemindMe
  End If
 End With
  If datStart <> datNull And datEnd <> datNull Then
  myItem.Start = datStart
  myItem.End = datEnd
  End If

myItem.Display
 
End Sub
==========

So oCalView.SelectedStartTime picks correct time regardless which calendar is selected. Appreciate if you could point me how to extract email address of calendar.

AlexP
 

AlexP

New Member
Outlook version
Outlook 2013 32 bit
Email Account
Outlook.com (as MS Exchange)
Hello Diane,
It's a shared exchange calendar.
 

AlexP

New Member
Outlook version
Outlook 2013 32 bit
Email Account
Outlook.com (as MS Exchange)
I mean calendar in a shared exchange account. It appears that I'm trying to mimic functionality of the Button 'New Meeting' -> 'New Meeting with All' but the meeting is created from a custom template..
 

AlexP

New Member
Outlook version
Outlook 2013 32 bit
Email Account
Outlook.com (as MS Exchange)
Hello Diana,
Yes, I actually need to pass the calendar name to the macro - I just can't figure out how to do it. I've got a shared calendar open, when I select a time slot in that shared calendar and run the macro it creates new appointment from my custom template, but ideally I also need to add owner of the shared calendar to the meeting invite.
Is there any way to get a reference to calendar name from selection?
 
Status
Not open for further replies.
Thread starter Similar threads Forum Replies Date
K VBA BeforeItemMove event create rule to always move to its folder. Outlook VBA and Custom Forms 4
D create an html table in outlook custom form 2010 using vba in MsAccess Outlook VBA and Custom Forms 7
Mark White vba to create a shared mailbox folder Outlook VBA and Custom Forms 3
Diane Poremsky Create a Series of Tasks using VBA New Slipstick.com Articles 0
Diane Poremsky Use VBA to create an Outlook Search Folder for Sender New Slipstick.com Articles 0
B VBA Code to create appointment from email Outlook VBA and Custom Forms 1
I shared mailbox - can i create a rule (vba) for every user? Outlook VBA and Custom Forms 1
Diane Poremsky Create a list of color categories and merge or restore the list using VBA New Slipstick.com Articles 0
P VBA create mail with attachment and voting buttons Using Outlook 6
J Create new outlook task into task subfolder using vba Using Outlook 6
C Outlook VBA - Create Macro Move Contact field Item to Another Using Outlook 1
L Macro/VBA to Reply All, with the original attachments Outlook VBA and Custom Forms 2
L VBA unknown character Outlook VBA and Custom Forms 2
G Move tasks up/down todo list by VBA Outlook VBA and Custom Forms 1
diver864 vba for a rule to automatically accept meeting requests with 'vacation' in subject, change to all-day event, change to free, don't send reply Outlook VBA and Custom Forms 1
K Use VBA to find Sender and Recipient from Microsfot 365 Journaled Email Items Outlook VBA and Custom Forms 3
J Want to learn VBA Macros for Outlook. What book can you recommend? Outlook VBA and Custom Forms 2
F VBA code to dock Styles whenever I write or edit an email Outlook VBA and Custom Forms 0
C VBA to prompt for Sent folder destination Outlook VBA and Custom Forms 3
B Adding signature to bottom of VBA reply email Outlook VBA and Custom Forms 1
B Change Font and Font size using VBA Outlook VBA and Custom Forms 9
M Outlook 2013 reminder email by using Outlook vba Outlook VBA and Custom Forms 2
D.Moore VBA script fail after Office 365 update Using Outlook 8
R Limiting length of saved attachment in VBA Outlook VBA and Custom Forms 2
S Skype for business meeting vba code Outlook VBA and Custom Forms 1
C How to use VBA to show only items x days old or more Outlook VBA and Custom Forms 1
B VBA to convert email to task, insert text of email in task notes, and attach copy of original email Outlook VBA and Custom Forms 4
D Outlook VBA error extracting property data from GetRules collection Outlook VBA and Custom Forms 10
S Reference Custom Fields with VBA Outlook VBA and Custom Forms 2
PGSystemTester VBA To Change AppointmentItem.BusyStatus From MeetingItem Before Send Using Outlook 0
A VBA macro for 15 second loop in send and received just for 1 specific mailbox Outlook VBA and Custom Forms 1
O Email not leaving Outbox when using Excel VBA to sync Outlook account Outlook VBA and Custom Forms 4
G VBA Macro Calendar Printing Assistant 4
R Help Revising VBA macro to delete email over different time span Outlook VBA and Custom Forms 0
B VBA to Collapse Task Folder Groups Outlook VBA and Custom Forms 1
R Expand VBA Permanent Delete Code Outlook VBA and Custom Forms 6
shrydvd vba to secure zip attachments Outlook VBA and Custom Forms 3
M Adding Subject to this Link-Saving VBA Outlook VBA and Custom Forms 5
N VBA to delete duplicates by message-id on common pst for 2 or more emails Outlook VBA and Custom Forms 0
S Change VBA script to send HTML email instead of text Outlook VBA and Custom Forms 3
M VBA to auto forward message with new subject and body text Outlook VBA and Custom Forms 8
A Custom VBA to sort emails into folders Outlook VBA and Custom Forms 0
L Moving emails with similar subject and find the timings between the emails using outlook VBA macro Outlook VBA and Custom Forms 1
B Outlook Business Contact Manager with SQL to Excel, User Defined Fields in BCM don't sync in SQL. Can I use VBA code to copy 1 field to another? BCM (Business Contact Manager) 0
R VBA for copying sent email to current folder under a shared mailbox Outlook VBA and Custom Forms 17
A Edit subject - and change conversationTopic - using VBA and redemption Outlook VBA and Custom Forms 2
N How can I increase/faster outlook VBA Macro Speed ? Using Outlook 2
N Outlook Email Rule execution through shortcut keys (VBA codes) Using Outlook 1
A VBA Code in Outlook disappears after first use Outlook VBA and Custom Forms 1
B Clear Offline Items (Mail Folder) via VBA Outlook VBA and Custom Forms 1
Similar threads


















































Top