vsto word 添加书签

 public static void SetBook(Document doc, string value, Bookmark mark, string markName)
        {
            try
            {
                var start = mark.Range.Start;
                var end = start + value.Length;
                mark.Range.Text = value;
                doc.ActiveWindow.Selection.SetRange(start, end);
                doc.ActiveWindow.Selection.Select();
                doc.Bookmarks.Add(markName, doc.ActiveWindow.Selection.Range);
            }
            catch (Exception ex)
            {
                LogManager.WriteError("", ex.StackTrace.ToString());
            }
        }

你可能感兴趣的:(vsto)