This project has moved and is read-only. For the latest updates, please go here.

C# multiple bookmarks same value

May 4, 2016 at 11:39 AM
Edited May 4, 2016 at 11:39 AM
How can I insert same value from one datagridview cells to multiple bookmarks inside word document? Here is working version for each bookmark, but I need to replace bookmarks with values from one datagridview, from example values from dataGridViewRow.Cells["Name"] to bookmarks inside doc called, Name, Name1, Name2 etc...
                        using (Novacode.DocX document = DocX.Load(template))
                        {

                            for (int i = 0; i < document.Bookmarks.Count; i++)
                            { 
                                
                                if (document.Bookmarks[i].Name != "_GoBack")
                                {
                                   
                                string s = dataGridViewRow.Cells[i+1].Value.ToString();
                                 document.Bookmarks[i].SetText(s);
                                   
                }
                 }

                document.SaveAs(path2);

            }