none
Visual Studio C# - Project 2010 Add-in - Cannot access ActiveProject.CustomDocumentProperties RRS feed

  • Question

  • Hi,

    I am trying to create a project 2010 add-in using Visual Studio 2010 that adds custom properties to Project 2010 document.
    (as specified in: "How to: Create and Modify Custom Document Properties")

    The following code: Microsoft.Office.Core.DocumentProperties properties = (Microsoft.Office.Core.DocumentProperties) Globals.ThisAddIn.Application.ActiveProject.CustomDocumentProperties;

    Either returns NULL or yield an RuntimeBInderException specifing "Cannot convert type 'string' to 'Microsoft.Office.Core.DocumentProperties'"

    I do know that CustomDocumentProperties exists because I can use it through VBA:
    Dim docProps As Office.DocumentProperties
    Set docProps = ActiveProject.CustomDocumentProperties

    Am I missing something?
    Any workaround?

    Thanks

    Moran


    • Edited by morang Tuesday, December 6, 2011 8:06 AM
    Thursday, November 17, 2011 9:23 AM

All replies

  • Hi Moran,

    Thanks for posting in the MSDN Forum.

    Do you ensure the CustomDocumentProperties exist? I tried to reproduce your issue on my side. However I get null of this property. Can you provide your sample Project file?

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Tuesday, November 22, 2011 6:11 AM
    Moderator
  • Hi Tom,

    I Re-run this again and got null for this property (as you did).

    Which cause the same problem for not being able to add my own custom properties.

    I know that CustomDocumentProperties exists because I can use it through VBA:

    Dim docProps As Office.DocumentProperties
    Set docProps = ActiveProject.CustomDocumentProperties

    Looking forward for your (Or other MS expert) assistance on this.

    Best Regards

    Moran

    Tuesday, November 22, 2011 10:34 AM
  • Hi morang,

     

    I can see what you mentioned on my side. I will involve some experts into this issue, I hope them can help you. There might be some time delay. Appreciate your patience.

     

    Have a good day,

     

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Wednesday, November 23, 2011 8:08 AM
    Moderator
  • Hi Tom,

    any news from the experts?

     

    Moran

    Wednesday, November 30, 2011 4:50 PM
  • Did you get a chance to go through the video?

     

    http://msdn.microsoft.com/en-us/vstudio/cc338010.aspx


    Cheers. Happy troubleshooting !!! Sriram E - MSFT Enterprise Project Management
    Saturday, December 3, 2011 4:17 AM
  • Not all applications can use every project type. For example, document-level projects are available only for Microsoft Office Word and Microsoft Office Excel. Similarly, some features are available only for certain types of projects or applications. For example, the actions pane is available only in document-level projects, and Ribbon extensions are available only for some applications.

    Based on the following article Document level customizations is not available for project2010 it seems.

    http://msdn.microsoft.com/en-us/library/aa942839.aspx


    Cheers. Happy troubleshooting !!! Sriram E - MSFT Enterprise Project Management
    Saturday, December 3, 2011 4:41 AM
  • Hello Sriram,

    It is well known that not all office application are supporting all type of features.

    "Custom Document Properties" are explicitly supported by Project 2010 (see the attached link in my initial question).
    And there is a Property " Globals.ThisAddIn.Application.ActiveProject.CustomDocumentProperties" to support this. There is a problem with the implementation of this property for C# that returns null (When I use this in VBA it returns the required object).

    You specify "Actions Pane" as an example for a feature that is not supported by all type of Office application. Pay attention that this is not a good example because this is not supported (For project 2010) only in the API level (There is no API function to get the CustomTaskPaneCollection) but as soon you are using:
    Globals.Factory.CreateCustomTaskPaneCollection (null, null, "CustomTaskPanes", "CustomTaskPanes", this);
    You may easily append Custom Task panes to other document types that are not supported in the API level.

    Looking forward for a real answer for this problem.

    Best Regards

    Moran Gavish
    Research Staff Member
    IBM - Haifa

     

    Sunday, December 4, 2011 6:30 AM
  • I am sorry.

    That article clearly tells me that its a document-level customization for Excel .

     

    Anyways, let me double check .....


    Cheers. Happy troubleshooting !!! Sriram E - MSFT Enterprise Project Management
    Sunday, December 4, 2011 10:54 PM
  • I am Quoting from MSDN under "How to: Create and Modify Custom Document Properties" :

    "Applies to: The information in this topic applies to document-level projects and application-level projects for the following applications: Excel 2007 and Excel 2010; PowerPoint 2007 and PowerPoint 2010; Project 2007 and Project 2010; Word 2007 and Word 2010".

    And this feature does working in project 2010 VBA.

    Please address this to someone that can solve this or at least suggest an workaround.

    Best regards

     

    Monday, December 5, 2011 7:15 AM
  • Hi Morang,

    Apart from a typo in your code - no space between "Microsoft.Office.Core.DocumentProperties" and "properties" - if I use your statement in the sample from the page you reference then this is working for me in C#, at least in debug.  Are you seeing it work in debug or not?Best regards,Brian.


    Blog | Facebook | Twitter | Posting is provided "AS IS" with no warranties, and confers no rights.
    Project Server TechCenter | Project Developer Center | Project Server Help | Project Product Page
    Monday, December 5, 2011 5:09 PM
  • Hi Brian

    Thanks for discovering my typo (corrected now...)

    I am using C# Visual studio 2010, creating project 2010 Addin.

    Consistently, the following code return null.

    On your side, Tom_Xu (previously commented on this post) experienced the same behavior.

    Are you getting a reference for this code?

    Best Reagards

    Morang

    Tuesday, December 6, 2011 8:36 AM