I am trying to use Interop.MSProject to do something that is conceptually, the most in the world The simplest thing is to do it. However, I'm having some trouble with its secret API which has the minimum documents. All I want to do is find the row in which one of them has a specific string (cell) and delete that line. After doing this, I want to display the modified project file so that the user Have the option of saving. Here I have tried:
MSProject.Application app = new MSProject.Application (); App. File OpenX (FilePath, False, Type Messaging, Type Missing, Type Missing, Type Missing, Type Missing, Type Missing, Type Missing, Type Missing, Type Missing, Msp.jpg.pzip Open PJP Reeldryt, type missing, type missing, type missing, type missing, type missing); Foreign (MSPOjkt. Work in Tasks) {if (task == null) continues; String cellValue = task.OutlineCode3; If (cellValue == searchString) works Remove (); } App Visible = true;
It seems that the task Deletate is not working. I have also tried to normalize this code:
foreach (proj.Tasks in MSP.ject.Task work) task.Delete ()
< P> And it does not work either Does anyone know that I can remove any work or line base for any value in one of the lines?
I had to face equality yesterday.
Your approach is correct, but it does not work because work index is based on it is clear for a straight loop.
If you have 10 tasks and delete one, let's say 5 numbers, now the next task (6) is now 5 but your loop will try to remove 6. Now it's 7. It will mess up everything.
If you want to delete all tasks, then you should do something like this:
// Task index is not 1-based based on 0 (int i = 1; i & lt; = proj.Tasks.Count; i ++) {proj.Tasks [i]. Delete (); I--; }
After this train it was thought that it is applied to a foreach loop.
Why am I using GetTaskIndexByGuid? It seems that the index property of each task is not properly (or emailed) if you delete the job, but I found that using GetTaskIndexByGuid always gives the correct indicator.
Hope this helps
Comments
Post a Comment