Pane
What is Pane in Word? Pane refers to frame under which the document is embedded. Word has Pane object which is inherited from Window object. We can perform various automated tasks with the Pane object as listed below:
- Methods
- Activate
- AutoScroll
- Close
- LargeScroll
- PageScroll
- NewFrameset
- SmallScroll
- TOCInFrameset
- Properties
- Application
- DisplayRulers
- BrowseWidth
- Creator
- DisplayVerticalRuler
- Document
- Frameset
- HorizontalPercentScrolled
- Index
- MinimumFontSize
- Next
- Pages
- Parent
- Previous
- Selection
- View
- VerticalPercentScrolled
- Zoom
Lets take an example where we want to show Rulers in active document by putting some code:

Code example
Public Sub DisplayRuler() 'Create application variable Dim oApp As Application 'Bind reference Set oApp = Word.Application 'bind pane reference Dim oPane As Pane Set oPane = oApp.ActiveWindow.ActivePane 'Toggle ruler oPane.DisplayRulers = True End Sub
Output

Prerequisites
C# code example
private void btnProtect_Click(object sender, RibbonControlEventArgs e) { //Bind application reference wordApp.Application oApplication = Globals.ThisAddIn.Application; //Binding Window reference wordApp.Window oWindow = oApplication.ActiveWindow; //Bind pane reference wordApp.Pane oPane = oWindow.ActivePane; //display ruler oPane.DisplayRulers = true; }
Vb.Net code example
Private Sub btnShowHideRulers_Click(sender As Object, e As RibbonControlEventArgs) Handles btnShowHideRulers.Click 'Bind application reference Dim oApplication As word.Application oApplication = Globals.ThisAddIn.Application 'Binding Window reference Dim oWindow As word.Window oWindow = oApplication.ActiveWindow 'Bind Pane object Dim oPane as word.Pane oPane=oWindow.ActivePane 'Display ruler oPane.DisplayRulers=True End Sub
Next >> Page Number object in Word Document VBA code