我正在尝试找到一种将 MS Project 文件以只读方式打开的快速方法,最好从资源管理器中打开。我正在按照教程头使用本教程从 excel 中执行相同的操作,该教程使用以下代码:
'-------------------- 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
但是当我尝试像这样为项目修改它时:
'-------------------- 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
MS Project 闪烁打开然后关闭。有任何想法吗?