PRJ98: Macro to Determine If a Project Is Opened as Read-Only

Support for Office 2003 has ended

Microsoft ended support for Office 2003 on April 8, 2014. This change has affected your software updates and security options. Learn what this means for you and how to stay protected.

This article has been archived. It is offered "as is" and will no longer be updated.
Summary
This article contains a sample macro that determines if a project is opened as read-only.
More information
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. For more information about how to use the sample code in this article, click the article number below to view the article in the Microsoft Knowledge Base:
173707 OFF97: How to Run Sample Code from Knowledge Base Articles

The following macro determines if an open project is read-only.

To create this macro, follow these steps:

For Project 98, 2000, 2002, 2003, and 2007:
  1. On the Tools menu, point to Macro, and then click Macros.
  2. In the Macro name box, type ROExample, and then click Create to open Visual Basic Editor.
  3. Create a macro by typing the following subroutine:
     Sub ROExample()    ' Test to see if the file was opened read-only.    If Activeproject.ReadOnly=True Then        MsgBox "File is read-only"    Else        MsgBox "File is not read-only"    End If End Sub						
  4. On the File menu, click Close and Return to Microsoft Project.
  5. On the Tools menu, point to Macro, and then click Macros.
  6. In the list of macros, click to select ROExample.
  7. Click Run.
For Project 2010:

  1. On the View tab, and in the Macros section, click the Macros button
  2. In the Macro name box, type ROExample, and then click Create to open Visual Basic Editor.
  3. Create a macro by typing the following subroutine:
  4. Sub RoExample()

    ‘Test to see if the file was opened read-only.

                    If Activeproject.ReadOnly=True Then

                         MsgBox “File is read-only”

                    Else

                         MsgBox “File is not read-only”

                    End if

    End Sub
  5. On the File menu, click Close and Return to Microsoft Project.
  6. On the View tab, and in the Macros section, click the Macros button.
  7. In the list of macros, click to select ROExample.
  8. Click Run.



For additional information about programming in Microsoft Project, please see the following article in the Microsoft Knowledge Base:
189266 PRJ98: Visual Basic Environment Training Manuals for MS Project
vba macro code
Properties

Article ID: 216495 - Last Review: 01/05/2015 10:28:26 - Revision: 6.0

  • Microsoft Project 98 Standard Edition
  • Microsoft Office Project Professional 2007
  • Microsoft Office Project Professional 2003
  • Microsoft Office Project Standard 2007
  • Microsoft Office Project Standard 2003
  • Microsoft Project 2000 Standard Edition
  • Microsoft Project 2002 Standard Edition
  • Microsoft Project 2002 Professional Edition
  • Microsoft Project Professional 2010
  • Microsoft Project Standard 2010
  • kbnosurvey kbarchive kbdtacode kbhowto kbprogramming KB216495
Feedback