2
Vote

Addcustomproperty not showing values in header

description

Hi,

i have 4 custom properties in my header, when i run the code im not getting any values in header. if i place the same custom properties out side the header( normal work space) i can get the values.

plx help me in solving this i was stuck with this from past 2 days and im trying all possible ways to slove this.

your help is highly appreciated. Thanks

comments

BoucherS wrote Apr 25 at 8:04 PM

Hi,

What code do you use.

This looks good :
// Loading the file
      _document = DocX.Load( @"test.docx" );
      // Add a custom property
      _document.AddCustomProperty( new CustomProperty( "AAA", "Xceed Software inc." ) );

      // in document
      _document.Paragraphs[ 8 ].AppendDocProperty( _document.CustomProperties["AAA"] );
      // in document header
      _document.Headers.Odd.Paragraphs.Last().AppendDocProperty( _document.CustomProperties[ "AAA" ] );

      _document.SaveAs( @"test5.docx" );