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

Article translations Article translations
Article ID: 216495 - View products that this article applies to.
This article was previously published under Q216495
Expand all | Collapse all

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

Properties

Article ID: 216495 - Last Review: September 18, 2011 - Revision: 5.0
APPLIES TO
  • 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
Keywords: 
kbdtacode kbhowto kbprogramming KB216495

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com