Results 1 to 9 of 9
  1. #1
    3 Star Lounger
    Join Date
    Nov 2001
    Location
    Upstate, South Carolina, USA
    Posts
    253
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Vertially Tiled Windows (O2002)

    Anyone know if there's a way to vertically tile Word documents inside the Word window, i.e., when not using the one-doc-file-per-window feature, instead of the default/only horizontal way?
    Al
    "Do or do not do. There is no try." -- Yoda
    <img src=/S/flags/USA.gif border=0 alt=USA width=30 height=18>

  2. #2
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    New York
    Posts
    214
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Vertially Tiled Windows (O2002)

    Here's a module/macro I wrote long ago ; If you create a module called WinSideBySide and paste this code into it, then assign it to the Windows menu, you'll be able to tile side by side. It will give you a list of open documents if there are more than two.


    <pre>
    Public Sub MAIN()
    Dim Magic
    Dim x
    Dim Y
    Dim CurDoc$
    ReDim Names__$(0)
    Dim i
    Dim dlgrec As Object
    Magic = WordBasic.CountWindows()
    If Magic < 2 Then GoTo bye
    Y = Application.UsableHeight - 4
    x = Application.UsableWidth / 2
    CurDoc$ = WordBasic.[WindowName$]()
    If Magic > 2 Then
    ReDim Names__$(Magic - 2)
    For i = 0 To Magic - 2
    Names__$(i) = WordBasic.[WindowName$](((WordBasic.Window() + i) Mod Magic) + 1)
    Next i
    WordBasic.BeginDialog 510, 50 + 12 * Magic, "WinSideBySide"
    WordBasic.Text 8, 8, 338, 13, WordBasic.[WindowName$]() + " next to:"
    WordBasic.ListBox 18, 30, 350, 12 * Magic - 8, Names__$(), "Window"
    WordBasic.OKButton 393, 24, 88, 21
    WordBasic.CancelButton 393, 48, 88, 21
    WordBasic.EndDialog
    Set dlgrec = WordBasic.CurValues.UserDialog
    dlgrec.Window = 0
    On Error GoTo -1: On Error GoTo bye
    WordBasic.Dialog.UserDialog dlgrec
    On Error GoTo -1: On Error GoTo 0
    WordBasic.Activate Names__$(dlgrec.Window)
    Else
    WordBasic.NextWindow
    End If
    If WordBasic.DocMaximize() Then WordBasic.DocMaximize
    If WordBasic.DocMinimize() Then WordBasic.DocRestore
    With ActiveWindow
    .WindowState = wdWindowStateNormal
    .Top = 0
    .Left = 0
    .Height = Y
    .Width = x
    End With
    WordBasic.Activate CurDoc$
    With ActiveWindow
    .WindowState = wdWindowStateNormal
    .Top = 0
    .Left = x
    .Height = Y
    .Width = x
    End With
    bye:
    End Sub

    </pre>


  3. #3
    3 Star Lounger
    Join Date
    Nov 2001
    Location
    Upstate, South Carolina, USA
    Posts
    253
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Vertially Tiled Windows (O2002)

    Thanks. I'll give it a whirl. Why do you think that the Word meisters at MSFT have not offered this capabaility?
    Al
    "Do or do not do. There is no try." -- Yoda
    <img src=/S/flags/USA.gif border=0 alt=USA width=30 height=18>

  4. #4
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    New York
    Posts
    214
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Vertially Tiled Windows (O2002)

    Here's the module with all WordBasic converted to VBA except for the dialog box code:

    <pre>Option Explicit

    Public Sub MAIN()
    Dim Magic
    Dim x
    Dim y
    Dim CurDoc$
    Dim dnames() As String
    Dim index
    Dim dlgrec As Object
    Dim dobj As Object

    Magic = Windows.Count 'WordBasic.CountWindows()

    If Magic < 2 Then
    ActiveWindow.WindowState = wdWindowStateMaximize
    Exit Sub
    End If

    y = Application.UsableHeight - 4
    x = Application.UsableWidth / 2

    CurDoc$ = WordBasic.[WindowName$]()
    CurDoc$ = ActiveDocument.Name

    If Magic > 2 Then
    For Each dobj In Documents
    If dobj.Name <> ActiveDocument.Name Then
    ReDim Preserve dnames(x)
    dnames(index) = dobj.Name
    index = index + 1
    End If
    Next

    WordBasic.BeginDialog 510, 50 + 12 * Magic, "WinSideBySide"
    WordBasic.Text 8, 8, 338, 13, CurDoc$ + " next to:"
    WordBasic.ListBox 18, 30, 350, 12 * Magic - 8, dnames(), "Window"
    WordBasic.OKButton 393, 24, 88, 21
    WordBasic.CancelButton 393, 48, 88, 21
    WordBasic.EndDialog
    Set dlgrec = WordBasic.CurValues.UserDialog
    dlgrec.Window = 0
    On Error GoTo -1: On Error GoTo bye
    WordBasic.Dialog.UserDialog dlgrec
    On Error GoTo -1: On Error GoTo 0


    Documents(dnames(dlgrec.Window)).Activate

    Else

    ActiveWindow.Next.Activate
    End If

    With ActiveWindow
    .WindowState = wdWindowStateNormal
    .Top = 0
    .Left = 0
    .Height = y
    .Width = x
    End With

    WordBasic.Activate CurDoc$
    Documents(CurDoc$).Activate

    With ActiveWindow
    .WindowState = wdWindowStateNormal
    .Top = 0
    .Left = x
    .Height = y
    .Width = x
    End With
    bye:
    End Sub
    </pre>


  5. #5
    3 Star Lounger
    Join Date
    Nov 2001
    Location
    Upstate, South Carolina, USA
    Posts
    253
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Vertially Tiled Windows (O2002)

    The <span style="background-color: #FFFF00; color: #000000; font-weight: bold">ActiveWindow.Next.Activate</span hi> statement produces the error <span style="background-color: #FFFF00; color: #000000; font-weight: bold">Object variable or With block variable not set (Error 91)</span hi>. I'm not enough of a VBA programmer (yet) to figure out how to fix this.
    Al
    "Do or do not do. There is no try." -- Yoda
    <img src=/S/flags/USA.gif border=0 alt=USA width=30 height=18>

  6. #6
    3 Star Lounger
    Join Date
    Nov 2001
    Location
    Upstate, South Carolina, USA
    Posts
    253
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Vertially Tiled Windows (O2002)

    Shot in the dark ...

    If one replaces
    <pre> ActiveWindow.Next.Activate</pre>

    with
    <pre> Set MyNextWindow = ActiveWindow.Next
    MyNextWindow.Activate
    </pre>

    then further down in the Sub, the statement
    <pre> .WindowState = wdWindowStateNormal
    </pre>

    generates the same error.
    Al
    "Do or do not do. There is no try." -- Yoda
    <img src=/S/flags/USA.gif border=0 alt=USA width=30 height=18>

  7. #7
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    New York
    Posts
    214
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Vertially Tiled Windows (O2002)

    That's odd. I took the code directly from the VBA help file on WordBAsic equivalents.

    So, until I figure out what the right VBA code is, you can just revert to the WordBasic:

    WordBasic.NextWindow

  8. #8
    5 Star Lounger
    Join Date
    May 2001
    Location
    Stuttgart, Baden-W, Germany
    Posts
    931
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Vertially Tiled Windows (O2002)

    There is something very funny about the commands to cycle the windows.

    According to the list of keyboard shortcuts, both Ctrl+F6 and Alt+F6 are linked to the same built-in command "NextWindow", but Ctrl+F6/Ctrl+Shift+F6 cycles through all open documents, whereas Alt+F6/Alt+Shift+F6 only switches beween the current and last current document.

    The code that recording Ctrl+F6 yields (ActiveWindow.Next.Activate) croaks for the "last" window in the list.
    Alt+F6 records the activated document directly (Windows("Dokument1").Activate, Windows("Dokument2").Activate, Windows("Dokument3").Activate), which isn't much help <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

    <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>Klaus

  9. #9
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    New York
    Posts
    214
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Vertially Tiled Windows (O2002)

    <hr>(ActiveWindow.Next.Activate) croaks for the "last" window in the list<hr>
    Which is why it was causing an error in my code, as this is called only if there are only two windows open. So it was switching to the last (the only other) in the list of open documents.

    Definitely a bug in VBA.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •