title: Using VBS to open MS Project file as read only
body: <p>I am trying to find a quick way to open MS Project files as read-only, preferrably from explorer. I was following the tutorial head to do the same thing from excel using <a href="http://answers.microsoft.com/en-us/office/forum/office_2007-excel/windows-7-context-menu-option-open-as-read-only/e28c9301-4ef0-4c0b-bc32-d92efb7be713?msgId=2ba1502f-50dc-4dd5-ba47-511c897b5bf6" rel="nofollow">this tutorial</a> which uses the following code:</p>
  
  <pre><code>'-------------------- Open as Read-Only.vbs --------------------
  Option Explicit
  
  Dim app 'As Object
  
  Call OpenAsReadOnly
  
  Sub OpenAsReadOnly()
     On Error Resume Next   
     Set app = GetObject(, "Excel.Application")
     If IsEmpty(app) Then Set app = CreateObject("Excel.Application")
  
     With app.Workbooks.Open(WScript.Arguments(0))
        If Not .ReadOnly Then .ChangeFileAccess 3 'xlReadOnly
        app.Visible = True
     End With
  End Sub
  </code></pre>
  
  <p>but when I try to modify it for Project like this:</p>
  
  <pre><code>'-------------------- Open as Read-Only.vbs --------------------
  Option Explicit
  
  Dim app 'As Object
  
  Call OpenAsReadOnly
  
  Sub OpenAsReadOnly()
     On Error Resume Next   
     Set app = GetObject(, "MSProject.Application")
     If IsEmpty(app) Then Set app = CreateObject("MSProject.Application")
  
     With app.Project.Open(WScript.Arguments(0))
        If Not .ReadOnly Then .ChangeFileAccess 3 'xlReadOnly
        app.Visible = True
     End With
  End Sub
  </code></pre>
  
  <p>MS Project flashes open then closes. Any ideas?</p>