/// <summary> /// Moves the focus to the appropriate header/footer. /// </summary> /// <param name="SelectionRange">The range containing the target header/footer.</param> /// <param name="sectionIdFinal">The section to be selected.</param> /// <param name="headerFooterId">The header/footer type to be selected.</param> internal static void MoveHeaderFooterFocus(Word.Range SelectionRange, int?sectionIdFinal, Word.WdHeaderFooterIndex?headerFooterId) { if (sectionIdFinal != null && headerFooterId != null) { Word.Window CurrentWindow = SelectionRange.Application.ActiveWindow; try { Word.Section CurrentSection = SelectionRange.Document.Sections[(int)sectionIdFinal]; if (!RedactCommon.GetHeaderFooterVisibility(CurrentSection, (Word.WdHeaderFooterIndex)headerFooterId) || CurrentWindow.View.Type != Word.WdViewType.wdPrintView) { //if that header/footer isn't being shown, we need to fall back into normal view CurrentWindow.View.Type = Word.WdViewType.wdNormalView; CurrentSection.Range.Select(); CurrentWindow.View.SplitSpecial = RedactCommon.GetSplitTypeForStory(SelectionRange.StoryType); } else { //select the appropriate section SelectionRange.Document.Sections[(int)sectionIdFinal].Range.Select(); //jump to the header/footer CurrentWindow.View.SeekView = RedactCommon.GetSeekViewForStory(SelectionRange.StoryType); Thread tTabSwitch = new Thread(StayOnReviewTab); tTabSwitch.Start(Redaction.Properties.Resources.ReviewTab); } } catch (COMException) { System.Diagnostics.Debug.Fail("incorrect header/footer view movement detected"); } } }