Question

My application allows the user to insert information into a document (using document properties and variables). Part of this is also that they should be able to adjust the values they have previously entered. Changing the Name and Value of a document property is no problem, but apparently the variable Name has a get property only, no set property. This is how I'm assigning a variable:

object v = _name;
Variables.Add(_sName, ref v);

This is how I'd ideally change the variable.

var.Name = newName;

But it gives an error saying:

Property or indexer 'Word.Variable.Name' cannot be assigned to -- it is read only

The only option I can think of is deleting the variable and creating a new one with the updated values. But is that really my only option?

Was it helpful?

Solution

I went ahead and solved it by simply changing the name and value of the document property, but also removing the variables and creating new ones with the updated values. As far as I know that's the only way to go about it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top