View Single Post
  #6  
Old March 1st, 2006, 02:54 PM posted to microsoft.public.word.tables
external usenet poster
 
Posts: n/a
Default Synchronise horizontal scroll of table in split screen

Jean-Guy,
I created a template & biult in your code. It works perfectly. Many thanks.
Charles

"Jean-Guy Marcil" wrote:

Charles Harrison was telling us:
Charles Harrison nous racontait que :

MS Word 2003.
I have my column headings in the top row of my table & have split the
screen so that I can add text to the other rows, whilst still being
able to view the headings. I'd like to be able to scroll holizontally
so that the headings remain aligned to the cells below them.


Try this code:

'_______________________________________
Sub ActivateKeysUpDown()

CustomizationContext = ActiveDocument.AttachedTemplate

KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyEnd), _
KeyCategory:=wdKeyCategoryMacro, _
Command:="GoLeft"

KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyHome), _
KeyCategory:=wdKeyCategoryMacro, _
Command:="GoRight"

End Sub
'_______________________________________

'_______________________________________
Sub GoRight()

Dim Doc1 As Pane
Dim Doc1Index As Long
Dim Doc2 As Pane
Dim Doc2Index As Long

With ActiveDocument.Windows(1)
If .Panes.Count = 2 Then

Set Doc1 = .ActivePane
Doc1Index = .ActivePane.Index
If Doc1Index = 1 Then
Doc2Index = 2
Else
Doc2Index = 1
End If
Set Doc2 = .Panes(Doc2Index)

Doc2.Activate
Doc2.SmallScroll ToLeft:=5
Doc1.Activate
Doc1.SmallScroll ToLeft:=5

Set Doc1 = Nothing
Set Doc2 = Nothing

Else

.ActivePane.SmallScroll ToLeft:=5

End If
End With

End Sub
'_______________________________________

'_______________________________________
Sub GoLeft()

Dim Doc1 As Pane
Dim Doc1Index As Long
Dim Doc2 As Pane
Dim Doc2Index As Long

With ActiveDocument.Windows(1)
If .Panes.Count = 2 Then

Set Doc1 = .ActivePane
Doc1Index = .ActivePane.Index
If Doc1Index = 1 Then
Doc2Index = 2
Else
Doc2Index = 1
End If
Set Doc2 = .Panes(Doc2Index)

Doc2.Activate
Doc2.SmallScroll ToRight:=5
Doc1.Activate
Doc1.SmallScroll ToRight:=5

Set Doc1 = Nothing
Set Doc2 = Nothing

Else

.ActivePane.SmallScroll ToRight:=5

End If
End With

End Sub
'_______________________________________

Run
ActivateKeysUpDown
(Alt-F8 from the main Word window) to activate the End-Home keys new
behaviour.
Change the value in the ToRight and ToLeft statement to get the scroll speed
you want.

This would work best with a template dedicated to those documents.

Create a template with the code, then attach that template to those
documents in which you want that double scrolling behaviour.

Else, change the line
CustomizationContext = ActiveDocument.AttachedTemplate
to
CustomizationContext = ActiveDocument
Add the code to the document itself (Not its template)
and run
ActivateKeysUpDown
to activate the keys.
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
ISTOO
Word MVP site:
http://www.word.mvps.org