J
Julian
Hi,
This is Word 2002... but I'd be surprised if it was unique to Word 2002...
Fed up with the DocumentMap not handling tables, I wrote my own outliner
that selectively shows and hides rows... worked a treat.
Then I discovered I needed some extra columns - but I've no screen estate
left, so I thought why not use a similar trick to show/hide one of a pair of
columns (well, alternate between v. small and "normal" width
Works OK BUT...
I only need one column of the pair at a time, so I set up a double-click
show/hide routine.
First, I hide a column by setting the font to hidden and then setting the
width to something small, then I show the other column by first setting the
width to "normal" AND ONLY THEN un-setting the font hidden attribute.
***** THE WEiRD BIT ******
What is weird is that when a previously "hidden" column is shown the text
ALWAYS appears in the "narrow" column (thereby causing the row height to go
crazy) even though I set the width first, before I unhide the text (it does
sort itself out a moment later, but it's hell on the eyes and it takes
time...)
Turning off screenupdating for the duration doesn't help, and no amount of
extra DoEvents calls or explicit repaginates will stop it... (all desperate
measures I admit...).
WHY? More to the point, can I stop it?
Thanks
Julian
PS I have just "purged" the template and reimported all modules, so I'm
confident there are no lurking corruptions...
Here's the code that does the business...
Sub toggleColumns(ByRef selDoc As Document, ByRef selCell As Cell)
Dim aCol As Column
Dim aCell As Cell
Application.ScreenUpdating = False
Set aCol = selCell.Range.Columns(1)
showHideColumn aCol:=aCol, show:=False ' First hide
a column
If selCell.ColumnIndex = scratchColIdx Then
Set aCol = selCell.Range.Rows(1).Cells(structureColIdx).Column
ElseIf selCell.ColumnIndex = structureColIdx Then
Set aCol = selCell.Range.Rows(1).Cells(scratchColIdx).Column
End If
showHideColumn aCol:=aCol, show:=True ' then show
the other one
Application.ScreenUpdating = True
End Sub
Sub showHideColumn(ByRef aCol As Column, ByVal show As Boolean)
Dim aCell As Cell
Dim oldSel As Range
If aCol Is Nothing Then Exit Sub
Set oldSel = Selection.Range
aCol.PreferredWidthType = wdPreferredWidthPoints
Select Case show
Case True
aCol.Select
aCol.PreferredWidth = InchesToPoints(3.01)
Selection.Font.Hidden = False
Case False
aCol.Select
Selection.Font.Hidden = True
aCol.PreferredWidth = InchesToPoints(0.01)
End Select
oldSel.Select
End Sub
This is Word 2002... but I'd be surprised if it was unique to Word 2002...
Fed up with the DocumentMap not handling tables, I wrote my own outliner
that selectively shows and hides rows... worked a treat.
Then I discovered I needed some extra columns - but I've no screen estate
left, so I thought why not use a similar trick to show/hide one of a pair of
columns (well, alternate between v. small and "normal" width
Works OK BUT...
I only need one column of the pair at a time, so I set up a double-click
show/hide routine.
First, I hide a column by setting the font to hidden and then setting the
width to something small, then I show the other column by first setting the
width to "normal" AND ONLY THEN un-setting the font hidden attribute.
***** THE WEiRD BIT ******
What is weird is that when a previously "hidden" column is shown the text
ALWAYS appears in the "narrow" column (thereby causing the row height to go
crazy) even though I set the width first, before I unhide the text (it does
sort itself out a moment later, but it's hell on the eyes and it takes
time...)
Turning off screenupdating for the duration doesn't help, and no amount of
extra DoEvents calls or explicit repaginates will stop it... (all desperate
measures I admit...).
WHY? More to the point, can I stop it?
Thanks
Julian
PS I have just "purged" the template and reimported all modules, so I'm
confident there are no lurking corruptions...
Here's the code that does the business...
Sub toggleColumns(ByRef selDoc As Document, ByRef selCell As Cell)
Dim aCol As Column
Dim aCell As Cell
Application.ScreenUpdating = False
Set aCol = selCell.Range.Columns(1)
showHideColumn aCol:=aCol, show:=False ' First hide
a column
If selCell.ColumnIndex = scratchColIdx Then
Set aCol = selCell.Range.Rows(1).Cells(structureColIdx).Column
ElseIf selCell.ColumnIndex = structureColIdx Then
Set aCol = selCell.Range.Rows(1).Cells(scratchColIdx).Column
End If
showHideColumn aCol:=aCol, show:=True ' then show
the other one
Application.ScreenUpdating = True
End Sub
Sub showHideColumn(ByRef aCol As Column, ByVal show As Boolean)
Dim aCell As Cell
Dim oldSel As Range
If aCol Is Nothing Then Exit Sub
Set oldSel = Selection.Range
aCol.PreferredWidthType = wdPreferredWidthPoints
Select Case show
Case True
aCol.Select
aCol.PreferredWidth = InchesToPoints(3.01)
Selection.Font.Hidden = False
Case False
aCol.Select
Selection.Font.Hidden = True
aCol.PreferredWidth = InchesToPoints(0.01)
End Select
oldSel.Select
End Sub