R
Ron
Using Word 2007, with templates in 2003 format that contain Field Codes
created by the user: { = myBookmark \# $#,##0.00 }
Using .Net C#, to iterate the Fields collection and replace "myBookmark"
with a value retrieved from an external source. The idea is to replace the
bookmark, but retain the user's desired formatting.
Problem is that when the user creates the field code and uses the "Formula"
dialog, Word creates the Field Code as: { { = myBookmark \# $#,##0.00 } }.
[Embedded FC w/n FC]. The bookmark is replaced, but upon opening the output
document {10000} is displayed after toggling the field codes TWICE.
Code used:
foreach (Microsoft.Office.Interop.Word.Field thisField in oWordDoc.Fields)
{
thisRange = thisField.Code;
if (thisField.Type == Microsoft.Office.Interop.Word.WdFieldType.wdFieldEmpty)
{
// bypass empty field code
}
else
{
thisRange.Text = thisRange.Text.Replace("`myBookmark", "10000");
thisField.Update();
}
}
Is there an approach to handle the outer field code properly?
created by the user: { = myBookmark \# $#,##0.00 }
Using .Net C#, to iterate the Fields collection and replace "myBookmark"
with a value retrieved from an external source. The idea is to replace the
bookmark, but retain the user's desired formatting.
Problem is that when the user creates the field code and uses the "Formula"
dialog, Word creates the Field Code as: { { = myBookmark \# $#,##0.00 } }.
[Embedded FC w/n FC]. The bookmark is replaced, but upon opening the output
document {10000} is displayed after toggling the field codes TWICE.
Code used:
foreach (Microsoft.Office.Interop.Word.Field thisField in oWordDoc.Fields)
{
thisRange = thisField.Code;
if (thisField.Type == Microsoft.Office.Interop.Word.WdFieldType.wdFieldEmpty)
{
// bypass empty field code
}
else
{
thisRange.Text = thisRange.Text.Replace("`myBookmark", "10000");
thisField.Update();
}
}
Is there an approach to handle the outer field code properly?