Doc I/O cannot display DocVariable Value


1) Not able to Access the DocVariable from Word document in my .cs file.


I looked at sample,

Created a DocVariable in my Word document....and later had this code in the .cs file.

WordDocument doc = new WordDocument();
doc.Open("Sample.doc");
DocVariables v = document1.Variables;
//Add a variable
v.Add("var1", "Author Name");
//Add / modify variables:
v["var2"] = "change name";
Console.WriteLine("Number of Variables:" + document1.Variables.Count.ToString());
Console.WriteLine("Variable Name:" + document1.Variables.GetNameByIndex(0));
Console.WriteLine("Varaible Value:" + document1.Variables.GetValueByIndex(0));

doc.Save("SampleModified.doc");

Now, I my problem was....I am not able to display the DocVariable value.


3 Replies

VS Vijayakumar S Syncfusion Team August 11, 2009 12:10 PM UTC

Hi Vinod,

Thank you for posting your query.

While we would strongly recommend that you use Direct Trac because you can take the advantage of the expertise of a dedicated support engineer and a guaranteed response time.

Could you please try this code snippet and let us know if this helps

WordDocument doc = new WordDocument();
doc.Open("Sample.docx", FormatType.Automatic);
DocVariables v = doc.Variables;
//Add a variable
v.Add("var1", "Author Name");
//Add / modify variables:
v["var2"] = "change name";
Console.WriteLine("Number of Variables:" + doc.Variables.Count.ToString());
Console.WriteLine("Variable Name:" + doc.Variables.GetNameByIndex(0));
Console.WriteLine("Varaible Value:" + doc.Variables.GetValueByIndex(0));

doc.Save("SampleModified.docx", FormatType.Docx);

Please let us know if you have any questions

Regards,
Vijay


VK Vinod K Bobba August 14, 2009 12:06 AM UTC

Hi Vijay,

That's exactly what I was doing, but the DocVariable value is only displayed when I right click on the variable and click edit field.

I tried to use macro to update the field and it works.


But the problem is, When I have the DocVariable nested in a Table, it doesn't work.

Let me know if you have any suggestions.



VS Vijayakumar S Syncfusion Team August 14, 2009 12:41 PM UTC

Hi Vinod,

Thank you for your update.

We were able to see the mentioned issue. We have forwarded this issue to our development team for further analysis. Could you please report this issue through Direct Trac Developer Support System https://www.syncfusion.com/account/login?ReturnUrl=%2fsupport%2fdirecttrac%2fincidents because you can take the advantage of the expertise of a dedicated support engineer and a guaranteed response time and we hope you will take advantage of this system as well. Thank you for your participation in Syncfusion’s Community Forums”.

Please let us know if you have any questions.

Regards,
Vijay

Loader.
Up arrow icon