public MemoryTextDocument() { this.storyRanges = new StoryRanges(); this.lines = new BaseList<ITextLine>(); this.selection = new TextSelection(this); this.selection.SelectionChanged += new EventHandlerT<ITextSelection>(selection_SelectionChanged); this.selection.OnGetRect += new EventHandler<GetRectEventArgs>(selection_OnGetRect); this.selection.OnGetText += new EventHandler<GetTextEventArgs>(selection_OnGetText); storyRanges.PropertyChanged += new PropertyChangedEventHandler(StoryRangesChanged); lines.PropertyChanged += new PropertyChangedEventHandler(LinesChanged); }
private static void ReplaceHyperlinks(Application word) { StoryRanges ranges = word.ActiveDocument.StoryRanges; foreach (Range range in word.ActiveDocument.StoryRanges) { foreach (Field field in range.Fields) { if (field.Type == WdFieldType.wdFieldHyperlink) { string text = field.Result.Text; string address = field.Result.Hyperlinks[1].Address; field.Result.Text = "[" + text + "](" + address + ")"; } } } }