Microsoft KB Archive/216495

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

Article ID: 216495

Article Last Modified on 1/24/2007

-

APPLIES TO


 * Microsoft Project 98 Standard Edition

-



This article was previously published under Q216495



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:

 On the Tools menu, point to Macro, and then click Macros. In the Macro name box, type ROExample, and then click Create to open Visual Basic Editor.  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  On the File menu, click Close and Return to Microsoft Project. On the Tools menu, point to Macro, and then click Macros. In the list of macros, click to select ROExample. Click Run.</li></ol>

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

Additional query words: vba macro code

Keywords: kbdtacode kbhowto kbprogramming KB216495

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.