VerticalAlignment Property

Microsoft Office Web Components Visual Basic

constant. Read/write Variant.

expression.VerticalAlignment

expression    Required. An expression that returns a Range object.

Example

This example top-aligns the contents of cells C7:G10 on Sheet1 in Spreadsheet1.

Sub SetAlignment()
   Dim rngAlign
   Dim ssConstants

   Set ssConstants = Spreadsheet1.Constants

   Set rngAlign = Spreadsheet1.Worksheets("Sheet1").Range("C7:G10")

   ' Center the contents of the range horizontally.
   rngAlign.HorizontalAlignment = ssConstants.xlHAlignCenter

   ' Vertically align the contents of the range at the top of the cells.
   rngAlign.VerticalAlignment = ssConstants.xlVAlignTop
End Sub