Can't Change Working Time After Running Macro to Edit Calendar

Last reviewed: November 24, 1997
Article ID: Q126986
The information in this article applies to:
  • Microsoft Project for Windows, version 4.0

SYMPTOMS

In 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.

CAUSE

This 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 = _
       False

when 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.

WORKAROUNDS

To work around this problem, use any of the following methods.

Method 1

Use 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 2

Use 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 Sub

Microsoft 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."

STATUS

Microsoft 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 INFORMATION

For 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

REFERENCES

For more information about the BaseCalendars Method, choose the Search button in the Visual Basic Reference and type:

    BaseCalendars

For more information about the Working Property, choose the Search button in the Visual Basic Reference and type:

    Working

For more information about the BaseCalendarEditDays Method, choose the Search button in the Visual Basic Reference and type:

    BaseCalendarEditDays


Additional query words: 4.00
Keywords : kbcode kbprg
Version : 4.0
Platform : WINDOWS
Issue type : kbprb


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: November 24, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.