在不同应用程序中的宏结束后,让使用 GetObject() 打开的 MS Project 文件打开并对用户可见的正确方法是什么?
我在网上找到的信息表明,在对象超出范围之前将Application.UserControl 属性设置为 True 应该允许用户继续使用打开的文件。但是,至少对于 MS Project,Application.UserControl 属性似乎是只读的。有没有办法解决这个问题?
显示问题的简化示例:
Sub AddTasks()
Dim proj As Object
' Already have the file path from another part of the workflow
Set proj = GetObject("C:\projtest.mpp")
' perform some calculations and add new tasks to project
proj.Tasks.Add "additional task"
' Leave Project open and visible for the user
proj.Application.Visible = True
proj.Application.UserControl = True ' Gives "Type Mismatch" error
' without the UserControl line, runs ok, but Project closes after the end of the macro
End Sub