Name

windows.CompareSideBySideWith(WindowName)

Synopsis

Starts side-by-side comparison between the active window and another window. Side-by-side comparison links the scrolling of the two windows so that you can more easily compare different versions of a workbook. Use BreakSideBySide to turn off this comparison.

The following code demonstrates turning side-by-side comparison on and off. Ordinarily, you would open two existing versions of a workbook, but I create the second version here so that the demonstration is self-contained:

Sub TestBeginSideBySide(  )
    Dim fpath As String, wnd As Window
    ' Get the window for active workbook.
    Set wnd = Application.ActiveWindow
    ' Get the workbook's full filename.
    fname = ActiveWorkbook.Path & "\" & ActiveWorkbook.name
    ' Change it to a new filename.
    fname = VBA.Replace(fname, ".xls", "_v2.xls")
    ' Save a copy of the workbook.
    ActiveWorkbook.SaveCopyAs fpath
    ' Open the copy (makes the copy the active window).
    Application.Workbooks.Open fname
    ' Turn on side-by-side comparision.
    Application.Windows.CompareSideBySideWith wnd.Caption
End Sub
 
Sub TestEndSideBySide(  )
    ' Turn off side-by-side comparision.
    Application.Windows.BreakSideBySide
End Sub

Get Programming Excel with VBA and .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.