none
Scroll to a Range on a Microsoft Word Split Window RRS feed

  • Question

  • I'm using the following code on a ribbon button click to spit the MS word Window,

    private void RibbonButton_Click(object sender, RibbonControlEventArgs e) {
    
       Window win = (Window) e.Control.Context;
       win.SplitVertical = 50;
    
    }

    I need to scroll to specific Ranges on each of the Split views. I tried selecting Ranges using the following code,

    Panes panes = win.Panes;
    foreach(Pane pane in panes){                                    
      Range r = pane.Document.Range(400, 405); // Sample range for testing                         
      r.Select();
    }

    But this code only scrolls to the Range on the Bottom view, but it does not scroll the Top view.

    Any ideas on this ?




    Tuesday, August 23, 2016 7:34 AM

Answers

  • >>>But this code only scrolls to the Range on the Bottom view, but it does not scroll the Top view.

    Any ideas on this ?<<<

    According to your description, I have made a sampe to check this issue, but this issue is not always reproduced.

    Panes panes = win.Panes;
    foreach (Pane pane in panes)
    {
       pane.Activate();
       Range r = pane.Document.Range(1200, 1250); // Sample range for testing                         
       r.Select();
    }



    The result:

    The workaround is that you could use VerticalPercentScrolled property:
    foreach (Pane pane in panes)
    {
        pane.Activate();
        pane.VerticalPercentScrolled = 2;
    }


    • Edited by David_JunFeng Wednesday, August 24, 2016 5:53 AM
    • Proposed as answer by David_JunFeng Wednesday, August 31, 2016 1:26 AM
    • Marked as answer by David_JunFeng Wednesday, August 31, 2016 8:38 AM
    Wednesday, August 24, 2016 5:48 AM