I
I
Ivan Baturin2020-06-04 12:30:32
C++ / C#
Ivan Baturin, 2020-06-04 12:30:32

Why does the value of only one link in a Word template change?

There is a template with calculations. Added bookmarks and links to these bookmarks in the document. In the program I change the value of these links, but only the very first one changes, why? Here is the code

private void SetTemplate(Word._Document oDoc)
        {
            oDoc.Bookmarks["Days"].Range.Text = Days.ToString();
            oDoc.Bookmarks["FOMS"].Range.Text = Math.Round(FOMS,2).ToString();
            oDoc.Bookmarks["FOT"].Range.Text = Math.Round(FOT, 2).ToString();
            oDoc.Bookmarks["FSS"].Range.Text = Math.Round(FSS, 2).ToString();
            oDoc.Bookmarks["KR"].Range.Text = Math.Round(KR, 2).ToString();
            oDoc.Bookmarks["PFR"].Range.Text = Math.Round(PFR, 2).ToString();
            oDoc.Bookmarks["Result"].Range.Text = Math.Round(Result, 2).ToString();
            oDoc.Bookmarks["RP"].Range.Text = Math.Round(RP, 2).ToString();
            oDoc.Bookmarks["Summary"].Range.Text = Math.Round(Summary, 2).ToString();
            oDoc.Bookmarks["Total"].Range.Text = Math.Round(PS, 2).ToString();
            oDoc.Bookmarks["ZP"].Range.Text = Math.Round(Zp, 2).ToString();

            oDoc.Hyperlinks["FOMS"].Range.Text = Math.Round(FOMS, 2).ToString();
            oDoc.Hyperlinks["FOT"].Range.Text = Math.Round(FOT, 2).ToString();
            oDoc.Hyperlinks["FSS"].Range.Text = Math.Round(FSS, 2).ToString();
            oDoc.Hyperlinks["KR"].Range.Text = Math.Round(KR, 2).ToString();
            oDoc.Hyperlinks["PFR"].Range.Text = Math.Round(PFR, 2).ToString();
            oDoc.Hyperlinks["Result"].Range.Text = Math.Round(Result, 2).ToString();
            oDoc.Hyperlinks["RP"].Range.Text = Math.Round(RP, 2).ToString();
            oDoc.Hyperlinks["Summary"].Range.Text = Math.Round(Summary, 2).ToString();
            oDoc.Hyperlinks["Total"].Range.Text = Math.Round(PS, 2).ToString();
        }


UPD: Here is an example template for more clarity
5ed8c02fe25f0598491158.png

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question