none
How to Add enterprise resource to a project in Addin RRS feed

  • Question

  • I want to create a project professional vsto project, it can automatically add enterprise resources to my project. I created a button on the ribbon, click on this button, I will be able to add some enterprise resources to this project. GUID  of these resources I already know, just do not know how to write code in VSTO.

    this is C# code of operate task:

                    Microsoft.Office.Interop.MSProject.Task task;
                    task = proj.Tasks.Add(taskclass.TaskName, 1);
                    task.Start = taskclass.TaskStartTime;
                    task.Finish = taskclass.TaskEndTime;
                    task.Text30 = taskclass.TaskUid.ToString();

    how to write C# code of operate resource?

    Tuesday, February 11, 2014 12:42 PM

All replies

  • Simplest way is to make it work in Project VBA then translate to VSTO. In VBA use:

    Application.EnterpriseResourceGet EUID

    So add the resource first then you can assign it.


    Rod Gill
    Author of the one and only Project VBA Book
    www.project-systems.co.nz

    Tuesday, February 11, 2014 6:24 PM
    Moderator
  • Please show me how to use Application.EnterpriseResourceGet,

    I dont't know how to use Parameter,I try it ,but no luck there.

    Wednesday, February 12, 2014 2:27 AM
  • Application.EnterpriseResourceGet ResourceGUID

    or

    Application.EnterpriseResourceGet "29BE0E58-9CF2-41F1-A9EF-11DCFC56BC69"

    You just have to convert the Application object to your Application object i the Add-in.

    Get your code working in VBA then translate to VB or C#, whichever you use.

    If it doesn't work (using your own Resource's GUID), then either you don't have the PWA permission needed to do this or your GUYID may be wrong.


    Rod Gill
    Author of the one and only Project VBA Book
    www.project-systems.co.nz

    Wednesday, February 12, 2014 2:56 AM
    Moderator
  • ************** 异常文本 **************
    System.Runtime.InteropServices.COMException (0x0000044D): 参数值无效。
       在 System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
       在 Microsoft.Office.Interop.MSProject._MSProject.EnterpriseResourceGet(Object EUID, Object RUID)
       在 ProjectWorkFlow.NeedEditTask.dgv_CellClick(Object sender, DataGridViewCellEventArgs e) 位置 H:\新电脑D\学习\SharePoint实例\ProjectWorkFlow\ProjectWorkFlow\ProjectWorkFlow\NeedEditTask.cs:行号 63

    have the PWA permission and guid is Correct

    Wednesday, February 12, 2014 3:31 AM
  • Globals.ThisAddIn.Application.EnterpriseResourceGet("97B3EBBF-871B-4ED6-B366-5EFE59B68F4A");
    Wednesday, February 12, 2014 3:31 AM
  • That looks better. VBA uses the Application object so the Globals.ThisAddIn.Application.EnterpriseResourceGet method matches it better.

    Rod Gill
    Author of the one and only Project VBA Book
    www.project-systems.co.nz

    Wednesday, February 12, 2014 6:17 AM
    Moderator