How to edit TimescaleStart from MS Project using C # .net

I have a requirement to modify the ms project file (.mpp) using C # .net.

I did with all things, the only thing left is to change the TimespaleStart date of the MPP file using C # .net. I need to set a user-defined date.

How can i do this?

Below is my code:

Microsoft.Office.Interop.MSProject.Application app = new Microsoft.Office.Interop.MSProject.Application(); app.DisplayAlerts = false; app.AskToUpdateLinks = false; app.FileOpenEx( strFilePath + "test.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); Microsoft.Office.Interop.MSProject.Project pj = app.ActiveProject; object objDate = dt.Date; app.TimescaleStart = objDate; 

Received error as

Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))

Next line:

 app.TimescaleStart = objDate; 
+6
source share
2 answers

TimescaleStart is a read-only property that returns the start date of the timeline in the current view.

If you want to scroll the view so that it starts from a specific date, find the task with a start date or closer to your target date, select it and call the GotoTaskDates method of the GotoTaskDates object. For instance:

  app.Find "Start", "is greater than or equal to", "1/1/2014", Type.Missing, Type.Missing, Type.Missing, Type.Missing app.GotoTaskDates 

Update:

If you are using Project 2010 or later, you can also use this method:

 app.PanZoomPanTo (objDate) 
+2
source

Maybe you are trying to change the start date of the project?

If this happens, try using the "ProjectMove" method. here here and here .

If you really want to change TimescaleStart, it looks like you're out of luck.

+1
source

Source: https://habr.com/ru/post/946848/


All Articles