A
Alex
Hi Everyone
I'm trying to create a piece of VBA code that will apply
preset cell shading and border formatting to either a
single cell or a group of selected cells, see below code:
Sub BlueCell()
With Selection.Shading
.Texture = wdTextureNone
.ForegroundPatternColor = wdColorAutomatic
.BackgroundPatternColor = RGB(200, 225, 250)
End With
Options.DefaultBorderLineStyle = wdLineStyleSingle
Options.DefaultBorderColor = RGB(0, 125, 200)
Options.DefaultBorderLineWidth = wdLineWidth050pt
With Selection.Borders
.OutsideLineStyle = Options.DefaultBorderLineStyle
.OutsideLineWidth = Options.DefaultBorderLineWidth
.OutsideColor = Options.DefaultBorderColor
End With
For Each Border In Selection.Borders
If Border.Inside = True Then
Border.LineStyle = Options.DefaultBorderLineStyle
Border.LineWidth = Options.DefaultBorderLineWidth
Border.Color = Options.DefaultBorderColor
End If
Next Border
End Sub
What I'm finding is that the codes works fine if I have
more than one table cell selected however, if I have a
single cell selected the code falls over within the IF...
Then... Else... statement at the:
Border.LineWidth = Options.DefaultBorderLineWidth
Can anyone help?
Big thank you in advance
Al
I'm trying to create a piece of VBA code that will apply
preset cell shading and border formatting to either a
single cell or a group of selected cells, see below code:
Sub BlueCell()
With Selection.Shading
.Texture = wdTextureNone
.ForegroundPatternColor = wdColorAutomatic
.BackgroundPatternColor = RGB(200, 225, 250)
End With
Options.DefaultBorderLineStyle = wdLineStyleSingle
Options.DefaultBorderColor = RGB(0, 125, 200)
Options.DefaultBorderLineWidth = wdLineWidth050pt
With Selection.Borders
.OutsideLineStyle = Options.DefaultBorderLineStyle
.OutsideLineWidth = Options.DefaultBorderLineWidth
.OutsideColor = Options.DefaultBorderColor
End With
For Each Border In Selection.Borders
If Border.Inside = True Then
Border.LineStyle = Options.DefaultBorderLineStyle
Border.LineWidth = Options.DefaultBorderLineWidth
Border.Color = Options.DefaultBorderColor
End If
Next Border
End Sub
What I'm finding is that the codes works fine if I have
more than one table cell selected however, if I have a
single cell selected the code falls over within the IF...
Then... Else... statement at the:
Border.LineWidth = Options.DefaultBorderLineWidth
Can anyone help?
Big thank you in advance
Al