We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Get Custom Document Properties | Advanced Properties | Word Document Variable Values using C#

using Aspose version 20.2.0.0
attached is template and code.

I am trying to get the list of custom variables that are in the template (there are 3), and don’t seem to be able to accomplish that.
getting the variable count returns 2.
when I iterate through the items, none of them are the custom variables. in fact, the first one has a blank name, and the second is named ‘title’
Variables.zip (13.8 KB)

@conniem,

Can you please elaborate a bit, what do you mean by there are three custom variables in your test.dot? Please also provide a screenshot highlighting the areas (custom variables) in this document that you want to retrieve by using Aspose.Words. We will then investigate the scenario on our end and provide you more information.

image.png (13.7 KB)
there are 3 custom variables in the document.
the code I attached is only returning 2, and they are not the correct ones.

To see them, go to properties | advanced, then go to the custom tab

@conniem,

You can retrieve these custom document properties in Word document by using the following code:

Console.WriteLine(doc.CustomDocumentProperties.Count);
foreach (DocumentProperty docProperty in doc.CustomDocumentProperties)
    Console.WriteLine("{0} : {1}", docProperty.Name, docProperty.Value);

thank you, was what I needed

@conniem,

Thanks for your feedback. Please let us know any time you may have any further queries in future.