Orienting a Style with xlVertical

A bug in Microsoft Excel 97 does not allow for the proper creation of a style if the orientation of the style is xlVertical. Thus the following code, which will work in Microsoft Excel 95, will not work in Microsoft Excel 97:

Sub NewStyle
     Set MyStyle = ThisWorkbook.Styles.Add(Name:="Test")
     MyStyle.Orientation = xlVertical
End Sub

Creating a style at run time is not common, and the vertical orientation is probably less so. Nevertheless, developers who create styles at run time should be aware of this bug and the following workaround:

Sub VerticalStyleWorkaround()
    With Selection
        .Orientation = xlVertical
        .HorizontalAlignment = xlGeneral
        .VerticalAlignment = xlBottom
    End With
    ActiveWorkbook.Styles.Add Name:="VerticalOrientation"
End Sub

Essentially, you must first create the style in a cell, and then add it to the selection (the coding equivalent of manually adding a style "by example").