Can't Change Working Time After Running Macro to Edit CalendarLast reviewed: November 24, 1997Article ID: Q126986 |
The information in this article applies to:
SYMPTOMSIn Microsoft Project, you may not be able to use the Change Working Time dialog box to change the working and nonworking days on the calendar after you run a macro that edits the base calendar.
CAUSEThis behavior occurs if you use the Working property in a Visual Basic, Applications Edition, macro to set the working or nonworking days for a date range on the base calendar. The problem occurs if the date range you specify extends beyond one month. When this occurs, you cannot use the Change Working Time dialog box to change the working time for the days in the second and following months in that date range. For example, if you run a macro that contains the following command
ActiveProject.BaseCalendars(1).Period("3/29/95", "5/5/95").Working = _ Falsewhen you open the Change Working Time dialog box, and select the month of April 1995, you cannot select the Working option for any of the days in this month. The Nonworking option remains selected for each day in the range 3/29/95 to 5/5/95.
WORKAROUNDSTo work around this problem, use any of the following methods.
Method 1Use the BaseCalendarEditDays Method to edit the base calendar as in the following example:
Sub ChangeWorkDays ' Set all days in the range 3/29/95 to 5/5/95 as nonworking BaseCalendarEditDays Name:="Standard", startDate:="3/29/95", _ endDate:="5/5/95", Working:=False End Sub Method 2Use the Working Property of the Period object with one month intervals. For example, use the following three commands to set the Working property to the value False for the entire range 3/29/95 to 5/5/95 instead of one command:
Sub ChangeWorkDays ActiveProject.BaseCalendars(1).Period("3/29/95","3/31/95").Working = _ False ActiveProject.BaseCalendars(1).Period("4/1/95","4/30/95").Working = _ False ActiveProject.BaseCalendars(1).Period("5/1/95","5/5/95").Working = _ False End SubMicrosoft provides examples of Visual Basic procedures for illustration only, without warranty either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose. This Visual Basic procedure is provided 'as is' and Microsoft does not guarantee that it can be used in all situations. Microsoft does not support modifications of this procedure to suit customer requirements for a particular purpose. Note that a line that is preceded by an apostrophe introduces a comment in the code--comments are provided to explain what the code is doing at a particular point in the procedure. Note also that an underscore character (_) indicates that code continues from one line to the next. You can type lines that contain this character as one logical line or you can divide the lines of code and include the line continuation character. For more information about Visual Basic for Applications programming style, see the "Programming Style in This Manual" section in the "Document Conventions" section of the "Visual Basic User's Guide."
STATUSMicrosoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.
MORE INFORMATIONFor additional information, please see the following article(s) in the Microsoft Knowledge Base:
ARTICLE-ID: Q126987 TITLE : Exceptions Lost After Running Macro to Edit Calendar REFERENCESFor more information about the BaseCalendars Method, choose the Search button in the Visual Basic Reference and type:
BaseCalendarsFor more information about the Working Property, choose the Search button in the Visual Basic Reference and type:
WorkingFor more information about the BaseCalendarEditDays Method, choose the Search button in the Visual Basic Reference and type:
BaseCalendarEditDays |
Additional query words: 4.00
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |