Quantcast
Channel: Project Customization and Programming forum
Viewing all articles
Browse latest Browse all 5347

MS Project 2007 - Calendar Exceptions - How to delete a calendar exception with VBA code?

$
0
0
I am working on various programmes developed by third party.
Quite often the calendars have incorrect exceptions.
How can I remove all exceptions at once without checking whether there are any, and them create new onces?

So far:

TO DELETE AN EXCEPTION:

Sub Delete_Exception ()
Dim cal As Calendar
Dim CalName As String
CalName = ActiveProject.Calendar.Name
ActiveProject.BaseCalendars(calName).Exceptions(1).Delete
End Sub

TO CREATE EXCEPTION:

Sub Create_Exception ()
Dim cal As Calendar
Dim CalName As String
CalName = ActiveProject.Calendar.Name
ActiveProject.BaseCalendars(CalName).Exceptions.Add Type:=1, Start:="22/03/2011", Finish:="22/04/2011", Name:="2013 Good Friday"
End Sub

The creation code works fine.
I have trouble with the deleting as it only works with one line.
how can I make it:
- first detect whether there is any exception in place
- secondly loop it in order to delete all data

Anybody, please? 



Viewing all articles
Browse latest Browse all 5347

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>