Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8294913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T14:23:57+00:00 2026-06-08T14:23:57+00:00

I am trying to delete future appointments in my Outlook calendar, from Access VBA,

  • 0

I am trying to delete future appointments in my Outlook calendar, from Access VBA, with the code below. The code works ok, BUT those Appointments have been set up using a room (resource), and deleting the appointment in MY calendar does not delete it in the resource calendar. How can I fix that ?

Sub NoFuture()
    'delete any future appointment
    Dim olApp As Outlook.Application
    Dim olNs As Outlook.NameSpace
    Dim olRecItems
    Dim olFilterRecItems
    Dim olItem As Outlook.AppointmentItem, strFilter As String

    Set olApp = CreateObject("Outlook.Application")
    Set olNs = olApp.GetNamespace("MAPI")
    Set olRecItems = olNs.GetDefaultFolder(olFolderCalendar)

    strFilter = "[Start] > '" & Format(Date + 1, "mm/dd/yyyy") & "'"
    Set olFilterRecItems = olRecItems.Items.Restrict(strFilter)

    For Each olItem In olFilterRecItems
        olItem.Delete
    Next olItem
    Set olRecItems = Nothing
    Set olNs = Nothing
    Set olApp = Nothing
End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T14:24:01+00:00Added an answer on June 8, 2026 at 2:24 pm

    Diane Poremsky has written a macro that goes through and removes cancelled appointments from the resource calender:

    ' A subroutine to remove cancelled appointments.
    Sub RemoveCanceledAppointments()  
    
    'Form variables.
    Dim OutLookResourceCalendar As Outlook.MAPIFolder, OutLookAppointmentItem As Outlook.AppointmentItem, IntegerCounter As Integer 
    
    'This sets the path to the resource calender.
    Set OutLookResourceCalendar = OpenMAPIFolder("\MailboxName\Calendar")  
    For IntegerCounter = OutLookResourceCalendar.Items.Count To 1 Step -1  
    
    Set OutLookAppointmentItem = OutLookResourceCalendar.Items(IntegerCounter)  
    
        If Left(OutLookAppointmentItem.Subject, 9) = "Canceled:" Then 
    
            OutLookAppointmentItem.Delete  
    
        End If 
    
    Next 
    
    Set OutLookAppointmentItem = Nothing 
    
    Set OutLookResourceCalendar = Nothing 
    
    End Sub 
    
     ' A function for the folder path.
    Function OpenMAPIFolder(FolderPathVar)  
    
    Dim SelectedApplication, FolderNameSpace, SelectedFolder, FolderDirectoryVar, i  
    
    Set SelectedFolder = Nothing 
    
    Set SelectedApplication = CreateObject("Outlook.Application")  
    If Left(FolderPathVar, Len("\")) = "\" Then 
    
        FolderPathVar = Mid(FolderPathVar, Len("\") + 1)  
    
    Else 
    
        Set SelectedFolder = SelectedApplication.ActiveExplorer.CurrentFolder  
    
    End If 
    
    While FolderPathVar <> "" 
    
    ' Backslash var.
    i = InStr(FolderPathVar, "\")  
    
            'If a Backslash is present, acquire the directory path and the folder path...[i].
            If i Then 
    
                FolderDirectoryVar = Left(FolderPathVar, i - 1)  
    
                FolderPathVar = Mid(FolderPathVar, i + Len("\"))  
    
            Else 
    
                '[i] ...or set the path to nothing.
                FolderDirectoryVar = FolderPathVar  
    
                FolderPathVar = "" 
    
            End If 
    
            ' Retrieves the folder name space from the Outlook namespace, unless a folder exists... [ii].
            If IsNothing(SelectedFolder) Then 
    
                Set FolderNameSpace = SelectedApplication.GetNamespace("MAPI")  
    
                Set SelectedFolder = FolderNameSpace.Folders(FolderDirectoryVar)  
    
            Else 
    
            ' [ii] in which case the the existing folder namespace is used.
                Set SelectedFolder = SelectedFolder.Folders(FolderDirectoryVar)  
    
            End If 
    
        Wend  
    
    Set OpenMAPIFolder = SelectedFolder  
    
    End Function 
    
    
     ' A function to check too see if there is no set namespace for the folder path.
    Function IsNothing(Obj)  
    
    If TypeName(Obj) = "Nothing" Then 
    
        IsNothing = True 
    
    Else 
    
        IsNothing = False 
    
    End If 
    
    End Function 
    

    Let me know if that removes the cancelled appointments from the resource calender –

    ~JOL

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I'm trying to delete an external event from my calendar, if I add
I'm trying to delete all calendar entries from today forward. I run a query
Im trying to delete one record from the database using LINQ. i have given
I am trying to delete multiple rows from a GridView but I am struggling
I am trying to delete a cookie with this function , but it doesnt
I am trying to delete MySQL table rows from a Web page using Perl.
I'm trying to delete a specific line by id from a file in C++
I'm trying to delete certain lines from a file. My file is a .txt
I am trying to delete the data present in the dataset with following code:
Im trying to delete an sdf file in the .NET mobile framework, but I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.