Dharma Records

A record of Ānandajoti’s publication work.

Menu
  • Notices
  • Talks
  • Texts
  • Audio
  • Video
  • Photos
  • Ecology
  • Culture
  • Archives
  • About
Menu

MS Word: Split Windows Vertically

Posted on October 5, 2013October 5, 2013 by Ānandajoti

Microsoft’s Winword provides a facility to split the screen of the active document horizontally, but not vertically.

I searched for a way to do this on the Net, and was surprised when I couldn’t find one, so I wrote a macro myself.

It doesn’t split in exactly the same way as the horizontal split works, but it is effective.

The VBA macro takes the active window, makes it two, and then arranges them side by side.

I have annotated the code so it can be easily read and modified, which you are allowed to do (GNU).

The code splits the window into equal halves, but with some small adjustments could split it 1/3-2/3 or any other dimensions you require.

The code was only tested in Word 97 and Word 2007.


Sub SplitVertically()

' script by Anandajoti (GNU license)
' this macro takes the active window makes it two
' and then arranges them side by side
' if the active window is already duplicated
' it closes the duplicate instead

Dim Win1 As Integer
Dim Win2 As Integer

Dim WinWidth As Integer
Dim WinHeight As Integer

' the first part is a toggle function
' it looks to see if there are windows
' that have already been duplicated
' and if there are it closes the 2nd
' and maximises the first
' and then exits

' if you don't want/need this part delete up to "Next Win"

Dim Win As Word.Window
Dim DocString As String
Dim FirstString
Dim SecondString
Dim StringLength As Long

For Each Win In Application.Windows
DocString = Win
FirstString = Right(DocString, 1)

    If FirstString = "1" Then
    
' if there is a duplicate
    
    StringLength = Len(DocString) - 2
    SecondString = Left(DocString, StringLength)
    
' close the copy

    Windows(SecondString & ":2").Close
    
' activate and maximise the doc that was found

    Windows(Win).Activate
    Windows(Win).WindowState = wdWindowStateMaximize
    
' jump to the end

    GoTo TheEnd
    
    End If

' otherwise check the next window

Next Win

' if there are no duplicates
' make sure the window is maximised
' so we can get the necessary dimensions
' the view it is in is unimportant

    ActiveWindow.WindowState = wdWindowStateMaximize

' find the serial number of the window
' we are dealing with and set the variable

    Win1 = ActiveWindow.Index

' set the dimension variables

    WinHeight = ActiveWindow.Height - 20
    WinWidth = ActiveWindow.Width

' make a new window from the first

    NewWindow

' find the serial number of the new window
    
    Win2 = ActiveWindow.Index
    
' arrange all windows (it won't work if the window is maximised)

    Windows.Arrange

' set the size of the two windows we found

    With Windows(Win1)
        .Left = 0
        .Top = 0
        .Height = WinHeight
        .Width = WinWidth / 2
    End With
    
    With Windows(Win2)
        .Left = WinWidth / 2
        .Top = 0
        .Height = WinHeight
        .Width = WinWidth / 2
    End With
   
' return to the first window

    Windows(Win1).Activate
    
TheEnd:
        
End Sub

or if you would prefer without annotation:


Sub SplitVertically()
Dim Win1 As Integer
Dim Win2 As Integer
Dim WinWidth As Integer
Dim WinHeight As Integer
Dim Win As Word.Window
Dim DocString As String
Dim FirstString
Dim SecondString
Dim StringLength As Long
For Each Win In Application.Windows
DocString = Win
FirstString = Right(DocString, 1)
    If FirstString = "1" Then
    StringLength = Len(DocString) - 2
    SecondString = Left(DocString, StringLength)
    Windows(SecondString & ":2").Close
    ws(Win).Activate
    Windows(Win).WindowState = wdWindowStateMaximize
       GoTo TheEnd
    End If
Next Win
    ActiveWindow.WindowState = wdWindowStateMaximize
    Win1 = ActiveWindow.Index
    WinHeight = ActiveWindow.Height - 20
    WinWidth = ActiveWindow.Width
    NewWindow
    Win2 = ActiveWindow.Index
    Windows.Arrange
    With Windows(Win1)
        .Left = 0
        .Top = 0
        .Height = WinHeight
        .Width = WinWidth / 2
    End With
    With Windows(Win2)
        .Left = WinWidth / 2
        .Top = 0
        .Height = WinHeight
        .Width = WinWidth / 2
    End With
    Windows(Win1).Activate
TheEnd: 
End Sub

If anyone can improve on the coding (and I wouldn’t be surprised) please leave a comment.

I hope this will be useful to others.

 

Split MS Word Screen Vertically

1 thought on “MS Word: Split Windows Vertically”

  1. Graham says:
    October 25, 2013 at 5:29 pm

    Anandajoti,

    Greetings from London, and thank you for this wonderful little macro – it’s just what I was looking for! If it’s of any interest, your page was one of the first to be listed by DuckDuckGo for the search query: “word 2007” arrange windows vertically

    Gratefully, Graham

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

QR code

SHORTLINK

RSS Feeds

  • All Posts
  • Texts
  • Photos

Donations

there are many expenses involved in the making of this website. Even a small donation really helps to maintain and expand the site.

choose amount:

Recent Posts

  • Two Innovative Temples in Petchabun
  • Two Photo Albums from Phimai Published
  • Photographs from Prasat Phanom Rung
  • Publication of the Introduction to the Jataka Stories
  • A Revised Presentation of the Jātaka Commentary
  • Comparative Dhammapada Table
  • Suttapitaka Index, with links to Pali Text and Translations
  • Karmavibhanga Stories Published in Hard Copy
  • Publication of The Theravāda Lineage (Nikāya Sangrahaya)
  • Paintings from the Thousand Buddhas Caves Published

Top 10 Tags

  • Books
  • Buddha
  • Dhamma
  • Ethics
  • India
  • Monks
  • Poetry
  • Sri Lanka
  • Temples
  • Wisdom

Recent Posts

  • Two Innovative Temples in Petchabun
  • Two Photo Albums from Phimai Published
  • Photographs from Prasat Phanom Rung
  • Publication of the Introduction to the Jataka Stories
  • A Revised Presentation of the Jātaka Commentary
  • Comparative Dhammapada Table
  • Suttapitaka Index, with links to Pali Text and Translations
  • Karmavibhanga Stories Published in Hard Copy
  • Publication of The Theravāda Lineage (Nikāya Sangrahaya)
  • Paintings from the Thousand Buddhas Caves Published

Other Posts

  • Summary of Publications during 2016
  • More Audio Files added to Godwin’s Archives
  • Glimpses of Ven. Nyanavimala
  • Complete Translation of The Analysis of Deeds Published
  • Father Bede Griffiths
  • BWV 067: Reconciliation and Responsibility
  • Photographs from Chedi Traiphop Traimongkhon
  • The Buddha discusses his Practice, Awakening and Decision to Teach
  • Somawati Stupa Vandana led by Kiribathgoda Gnanananda Thero
  • Improved Audio and Search Facilities on Ancient Buddhist Texts

Related Posts

  • Creating New Tags in Html5
  • Resize images to Fit Browser Window
  • Pan and Zoom style Slidehows on the Photo Dharma website
© 2021 Dharma Records | Powered by Minimalist Blog WordPress Theme