如何在MSProject项目上设置日历属性?

时间:2013-02-05 15:26:30

标签: c# interop ms-project

我有一个MSProject项目,我想更改正在使用的日历。问题是我找不到这个属性。

在这里,我展示了我的代码:

Microsoft.Office.Interop.MSProject.Application app = new Microsoft.Office.Interop.MSProject.Application();


 app.FileOpenEx(
                Server.MapPath("") + "\\sample.mpp",
                false,
                Type.Missing,
                Type.Missing,
                Type.Missing,
                Type.Missing,
                Type.Missing,
                Type.Missing,
                Type.Missing,
                Type.Missing,
                Type.Missing,
                PjPoolOpen.pjPoolReadWrite,
                Type.Missing,
                Type.Missing,
                Type.Missing,
                Type.Missing,
                Type.Missing);
                pj=app.ActiveProject;

//"proyecto" is an entity
//app.GlobalBaseCalendars has all calendars
                foreach (Microsoft.Office.Interop.MSProject.Calendar calendar in app.GlobalBaseCalendars)
                {
                    if (calendar.Name == "Noche")
                    {
                        pj.Calendar.index? GUID? ...= // All properties are read-only
                    }
                }

如何设置pj.Calendar

的值

1 个答案:

答案 0 :(得分:0)

这是项目属性是只读的许多情况之一,设置它的方法是使用应用程序的方法:

app.ProjectSummaryInfo(
                       Type.Missing,
                       Type.Missing,
                       Type.Missing,
                       Type.Missing,
                       Type.Missing,
                       Type.Missing,
                       Type.Missing,
                       Type.Missing,
                       Type.Missing,
                       Type.Missing,
                       Type.Missing,
                       Type.Missing,
                       "Noche",
                       Type.Missing,
                       Type.Missing,
                       Type.Missing);