N
Newt
I'm using the following VBA to hide rows based on the selected checkboxes.
However, if I close the document and then reopen it, the hidden rows appear,
but sort of squashed. Any ideas?
Sub AutoOpen()
Dim myArray1() As Variant
Dim myArray2() As Variant
myArray1 = Array("Regular", "24 Hour Priority", "Same Day Urgent")
With ComboBox1
..Clear
..List() = myArray1
End With
myArray2 = Array("Test1", "Test2", "Test3")
With ComboBox2
..Clear
..List() = myArray2
End With
End Sub
Private Sub CheckBox1_Click()
CheckBox1.Font.Bold = CheckBox1.Value
If CheckBox1.Value = False Then
CheckBox1.Font.Size = 10
ActiveDocument.Tables(1).Rows(2).Range.Font.Hidden = False
Else
CheckBox1.Font.Size = 12
ActiveDocument.Tables(1).Rows(2).Range.Font.Hidden = True
End If
End Sub
Private Sub CheckBox2_Click()
CheckBox2.Font.Bold = CheckBox2.Value
If CheckBox2.Value = False Then
CheckBox2.Font.Size = 10
ActiveDocument.Tables(1).Rows(1).Range.Font.Hidden = False
With ActiveDocument.Tables(1).Rows(2).Borders(wdBorderTop)
.LineStyle = wdLineStyleDot
.LineWidth = wdLineWidth025pt
.Color = wdColorGray25
End With
Else
CheckBox2.Font.Size = 12
ActiveDocument.Tables(1).Rows(1).Range.Font.Hidden = True
With ActiveDocument.Tables(1).Rows(2).Borders(wdBorderTop)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth225pt
.Color = wdColorBlack
End With
End If
End Sub
Private Sub CheckBox3_Click()
CheckBox3.Font.Bold = CheckBox2.Value
If CheckBox3.Value = False Then
CheckBox3.Font.Size = 10
ActiveDocument.Tables(1).Rows(1).Range.Font.Hidden = False
With ActiveDocument.Tables(1).Rows(2).Borders(wdBorderTop)
.LineStyle = wdLineStyleDot
.LineWidth = wdLineWidth025pt
.Color = wdColorGray25
End With
Else
CheckBox3.Font.Size = 12
ActiveDocument.Tables(1).Rows(1).Range.Font.Hidden = True
With ActiveDocument.Tables(1).Rows(2).Borders(wdBorderTop)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth225pt
.Color = wdColorBlack
End With
End If
End Sub
Private Sub CheckBox4_Click()
CheckBox4.Font.Bold = CheckBox2.Value
If CheckBox4.Value = False Then
CheckBox4.Font.Size = 10
ActiveDocument.Tables(1).Rows(1).Range.Font.Hidden = False
With ActiveDocument.Tables(1).Rows(2).Borders(wdBorderTop)
.LineStyle = wdLineStyleDot
.LineWidth = wdLineWidth025pt
.Color = wdColorGray25
End With
Else
CheckBox4.Font.Size = 12
ActiveDocument.Tables(1).Rows(1).Range.Font.Hidden = True
With ActiveDocument.Tables(1).Rows(2).Borders(wdBorderTop)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth225pt
.Color = wdColorBlack
End With
End If
End Sub
Private Sub CheckBox5_Click()
CheckBox5.Font.Bold = CheckBox2.Value
If CheckBox5.Value = False Then
CheckBox5.Font.Size = 10
ActiveDocument.Tables(1).Rows(1).Range.Font.Hidden = False
With ActiveDocument.Tables(1).Rows(2).Borders(wdBorderTop)
.LineStyle = wdLineStyleDot
.LineWidth = wdLineWidth025pt
.Color = wdColorGray25
End With
Else
CheckBox5.Font.Size = 12
ActiveDocument.Tables(1).Rows(1).Range.Font.Hidden = True
With ActiveDocument.Tables(1).Rows(2).Borders(wdBorderTop)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth225pt
.Color = wdColorBlack
End With
End If
End Sub
However, if I close the document and then reopen it, the hidden rows appear,
but sort of squashed. Any ideas?
Sub AutoOpen()
Dim myArray1() As Variant
Dim myArray2() As Variant
myArray1 = Array("Regular", "24 Hour Priority", "Same Day Urgent")
With ComboBox1
..Clear
..List() = myArray1
End With
myArray2 = Array("Test1", "Test2", "Test3")
With ComboBox2
..Clear
..List() = myArray2
End With
End Sub
Private Sub CheckBox1_Click()
CheckBox1.Font.Bold = CheckBox1.Value
If CheckBox1.Value = False Then
CheckBox1.Font.Size = 10
ActiveDocument.Tables(1).Rows(2).Range.Font.Hidden = False
Else
CheckBox1.Font.Size = 12
ActiveDocument.Tables(1).Rows(2).Range.Font.Hidden = True
End If
End Sub
Private Sub CheckBox2_Click()
CheckBox2.Font.Bold = CheckBox2.Value
If CheckBox2.Value = False Then
CheckBox2.Font.Size = 10
ActiveDocument.Tables(1).Rows(1).Range.Font.Hidden = False
With ActiveDocument.Tables(1).Rows(2).Borders(wdBorderTop)
.LineStyle = wdLineStyleDot
.LineWidth = wdLineWidth025pt
.Color = wdColorGray25
End With
Else
CheckBox2.Font.Size = 12
ActiveDocument.Tables(1).Rows(1).Range.Font.Hidden = True
With ActiveDocument.Tables(1).Rows(2).Borders(wdBorderTop)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth225pt
.Color = wdColorBlack
End With
End If
End Sub
Private Sub CheckBox3_Click()
CheckBox3.Font.Bold = CheckBox2.Value
If CheckBox3.Value = False Then
CheckBox3.Font.Size = 10
ActiveDocument.Tables(1).Rows(1).Range.Font.Hidden = False
With ActiveDocument.Tables(1).Rows(2).Borders(wdBorderTop)
.LineStyle = wdLineStyleDot
.LineWidth = wdLineWidth025pt
.Color = wdColorGray25
End With
Else
CheckBox3.Font.Size = 12
ActiveDocument.Tables(1).Rows(1).Range.Font.Hidden = True
With ActiveDocument.Tables(1).Rows(2).Borders(wdBorderTop)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth225pt
.Color = wdColorBlack
End With
End If
End Sub
Private Sub CheckBox4_Click()
CheckBox4.Font.Bold = CheckBox2.Value
If CheckBox4.Value = False Then
CheckBox4.Font.Size = 10
ActiveDocument.Tables(1).Rows(1).Range.Font.Hidden = False
With ActiveDocument.Tables(1).Rows(2).Borders(wdBorderTop)
.LineStyle = wdLineStyleDot
.LineWidth = wdLineWidth025pt
.Color = wdColorGray25
End With
Else
CheckBox4.Font.Size = 12
ActiveDocument.Tables(1).Rows(1).Range.Font.Hidden = True
With ActiveDocument.Tables(1).Rows(2).Borders(wdBorderTop)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth225pt
.Color = wdColorBlack
End With
End If
End Sub
Private Sub CheckBox5_Click()
CheckBox5.Font.Bold = CheckBox2.Value
If CheckBox5.Value = False Then
CheckBox5.Font.Size = 10
ActiveDocument.Tables(1).Rows(1).Range.Font.Hidden = False
With ActiveDocument.Tables(1).Rows(2).Borders(wdBorderTop)
.LineStyle = wdLineStyleDot
.LineWidth = wdLineWidth025pt
.Color = wdColorGray25
End With
Else
CheckBox5.Font.Size = 12
ActiveDocument.Tables(1).Rows(1).Range.Font.Hidden = True
With ActiveDocument.Tables(1).Rows(2).Borders(wdBorderTop)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth225pt
.Color = wdColorBlack
End With
End If
End Sub