none
Cannot Reference DocumentFormat.OpenXml.Office2010.Word.DrawingShape Namespace Using Open XML SDK 2.0 for Microsoft Office RRS feed

  • Question

  • According to the MSDN documentation I should be able to utilise the classes within the DocumentFormat.OpenXml.Office2010.Word.DrawingShape namespace(s) with version 2.0 of the Open XML SDK.

    I need to manipulate the contents of text boxes in a Word 2010 document but am unable to work with any tags that use the wps namespace (xmlns:wps=http://schemas.microsoft.com/office/word/2010/wordprocessingShape).

    If I use the Object Browser in Visual Studio 2013 to look at the DocumentFormat.OpenXml assembly, none of the DocumentFormat.OpenXml.Office2010 and associated namespaces are available.

    If I reference the 2.5 version of the SDK then everything is fine.

    My problem is that due to a third party assembly I must use version 2.0 since I am not able to use framework 4 with my application.

    Is it me or is the documentation wrong?


    • Edited by John Hussey Tuesday, January 7, 2014 11:37 AM
    Tuesday, January 7, 2014 11:35 AM

Answers

  • Hi DAvid

    Yes, I corrected myself in the second part of my previous reply...

    As mentioned there, I can create a using statement for the namespace and I can then do:

    wps.WordprocessingShape wwps = new wps.WordprocessingShape();

    And I double-checked my reference to the SDK, it's the runtime version v2.0.50727


    Cindy Meister, VSTO/Word MVP, my blog

    • Marked as answer by John Hussey Wednesday, January 8, 2014 10:53 AM
    Wednesday, January 8, 2014 9:59 AM
    Moderator

All replies

  • Hi John

    No problems here...

    Are you sure this document hasn't been saved in the 2007 compatibility mode? That would preclude use of the 2010 namespaces, even if the document were saved in Word 2010.

    Edit: I may have misread your message first time through but still, I don't have any problems. I can create a using statement for the namespace and declare objects in the namespace. Can you share some sample code that's not working for you?


    Cindy Meister, VSTO/Word MVP, my blog


    Wednesday, January 8, 2014 9:21 AM
    Moderator
  • Hi Cindy.

    The document hasn't been saved in 2007 compatibility mode but I think you may have been distracted from the fundamental issue.

    Let's take the document out of the equation and concentrate on the version 2.0 object library.

    If the following statement...

    Dim test As DocumentFormat.OpenXml.Office2010.Word.DrawingShape.WordprocessingShape
    ...is written while referencing version 2.5 of the Open XML SDK everything is fine.

    If you then change the reference to version 2.0 of the Open XML SDK Visual Studio prompts:

    "Error 102 Type 'DocumentFormat.OpenXml.Office2010.Word.DrawingShape.WordprocessingShape' is not defined."

    http://msdn.microsoft.com/en-us/library/documentformat.openxml.office2010.word.drawingshape.wordprocessingshape(v=office.14).aspx says that this should be available in version 2.0.

    I hope this simplifies things.

    Wednesday, January 8, 2014 9:42 AM
  • Hi DAvid

    Yes, I corrected myself in the second part of my previous reply...

    As mentioned there, I can create a using statement for the namespace and I can then do:

    wps.WordprocessingShape wwps = new wps.WordprocessingShape();

    And I double-checked my reference to the SDK, it's the runtime version v2.0.50727


    Cindy Meister, VSTO/Word MVP, my blog

    • Marked as answer by John Hussey Wednesday, January 8, 2014 10:53 AM
    Wednesday, January 8, 2014 9:59 AM
    Moderator
  • Hi DAvid

    No offence ;-)

    And I double-checked my reference to the SDK, it's the runtime version v2.0.50727

    Good old Microsoft. I downloaded the SDK quite some time ago and was working with v2.0.4330.

    I've just downloaded it again and it's v2.0.5022 (still not v2.0.50727 like you have).

    The good news is that I now have the correct namespaces available.

    It's lucky you posted your version number as this could have gone on for ages.

    Thanks.

    John (not DAvid (sic))


    • Edited by John Hussey Wednesday, January 8, 2014 10:53 AM
    Wednesday, January 8, 2014 10:52 AM
  • Hi JOHN (<sigh> sorry, so much going on...)

    Thanks for reporting back that the newer download resolved the issue. Isn't it wonderful, how such things aren't made public?

    Yes, it seemed strange to me that I could see it and you couldn't, so checking the version of the version did seem logical :-)


    Cindy Meister, VSTO/Word MVP, my blog

    Wednesday, January 8, 2014 11:13 AM
    Moderator