How to make Aspose Words tell me a variable in a template does not exist in the code?

I have created a scenario where my template contains a variable that does not exist in the code. Preferably I’d like Aspose to throw an exception (either during build or runtime) .
Is there some feature in Aspose I could use to achieve this goal?
Thanks in advance.

@Teije

Thanks for your inquiry. The Document.Variables property returns the collection of variables added to a document or template. You can find the desired variable from the collection using this property. Below code example shows how to enumerate over document variables. Hope this helps you.

Document doc = new Document(MyDir + "Document.doc");

foreach (KeyValuePair<string, string> entry in doc.Variables)
{
    String name = entry.Key;
    String value = entry.Value;

    // Do something useful.
    Console.WriteLine("Name: {0}, Value: {1}", name, value);
}

Since I am using the Template Syntax of aspose I am not sure if this works.
I have used a variable like this in the template: <<[VariableName]>> and for some reason it just ignores it when it does not exist in the code file backing this template.

@Teije

Thanks for your inquiry. To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input Word document.
  • Please attach the expected output Word file that shows the desired behavior.
  • Please create a standalone console application ( source code without compilation errors ) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.