Table of contents
Collapse the table of content
Expand the table of content

Application.AlignTableCellTop Method (Project)

office 365 dev account|Last Updated: 6/12/2017
1 Contributor

Aligns text at the top of the cell, for selected cells in a report table.


expression. AlignTableCellTop

expression A variable that represents an Application object.

Return value



In the following example, the AlignTableCells macro aligns the text for all tables in the specified report.

Sub TestAlignReportTables()
    Dim reportName As String
    Dim alignment As String   ' The value can be "top", "center", or "bottom".

    reportName = "Align Table Cells Report"
    alignment = "top"

    AlignTableCells reportName, alignment
End Sub

' Align the text for all tables in a specified report.
Sub AlignTableCells(reportName As String, alignment As String)
    Dim theReport As Report
    Dim shp As Shape

    Set theReport = ActiveProject.Reports(reportName)

    ' Activate the report. If the report is already active,
    ' ignore the run-time error 1004 from the Apply method.
    On Error Resume Next
    On Error GoTo 0

    For Each shp In theReport.Shapes
        Debug.Print "Shape: " &; shp.Type &; ", " &; shp.Name

        If shp.HasTable Then

            Select Case alignment
                Case "top"
                Case "center"
                Case "bottom"
                Case Else
                    Debug.Print "AlignTableCells error: " &; vbCrLf _
                        &; "alignment must be top, center, or bottom."
                End Select
        End If
    Next shp
End Sub

See also


Application Object

Other resources

Report ObjectAlignTableCellVerticalCenter MethodAligntableCellBottom Method

© 2018 Microsoft