Consulting

Results 1 to 2 of 2

Thread: Automatically updating fields each time an appointment is created

  1. #1
    VBAX Newbie
    Joined
    Apr 2015
    Location
    Israel
    Posts
    5
    Location

    Automatically updating fields each time an appointment is created

    Hello,
    I'm looking to create a macro which will automatically update 3 fields each time I create a new appointment -
    1. "Show as" = Free
    2. "Reminder" = 0 minutes
    3. "Category" = the blue category

    Is the above possible with a Macro?
    Thank you,

    -Noam

  2. #2
    It is easy enough to create an appointment with a macro, and add whatever options you wish:

    Option Explicit
    'Graham Mayor - https://www.gmayor.com - Last updated - 24 Dec 2020 
    Sub TestMeeting()
        CreateAppointment "Strategy Meeting",  "Conference Room", "12/29/2017", "14:00", 30, True, "John Smith", "Bill  Jones", "Meeting to discuss planning for Christmas holidays",  olNonMeeting
    lbl_Exit:
        Exit Sub
    End Sub
    
    Sub CreateAppointment(strSubject As String, _
                          strLocation As String, _
                          strBodyText As String, _
                          strDate As String, _
                          strTime As String, _
                          Optional iMinutes As Integer, _
                          Optional bAllDay As Boolean = True, _
                          Optional strName1 As String, _
                          Optional strName2 As String, _
                          Optional lngStatus As Long = olNonMeeting)
    
    Dim olItem As AppointmentItem
    Dim rRequiredAttendee As Recipient
    Dim rOptionalAttendee As Recipient
    Dim olInsp As Outlook.Inspector
    Dim wdDoc As Object
    Dim oRng As Object
    
        Set olItem = CreateItem(olAppointmentItem)
        With olItem
            .MeetingStatus = lngStatus
            .Subject = strSubject
            .Location = strLocation
            .Start = strDate & Chr(32) & strTime        ' & strAMPM
            .Duration = iMinutes
            .AllDayEvent = bAllDay
            
            'add other options as required here
            
            Set rRequiredAttendee = .Recipients.Add(strName1)
            rRequiredAttendee.Type = olRequired
            Set rOptionalAttendee = .Recipients.Add(strName2)
            rOptionalAttendee.Type = olOptional
            .Display
            Set olInsp = .GetInspector
            Set wdDoc = olInsp.WordEditor
            Set oRng = wdDoc.Range
            oRng.Text = strBodyText
        End With
        Set olItem = Nothing
        Set rRequiredAttendee = Nothing
        Set rOptionalAttendee = Nothing
        Set olInsp = Nothing
        Set wdDoc = Nothing
        Set oRng = Nothing
    lbl_Exit:
        Exit Sub
    End Sub
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •