Skip to content

Latest commit

 

History

History
91 lines (62 loc) · 2.31 KB

Project.application.aligntablecellverticalcenter.md

File metadata and controls

91 lines (62 loc) · 2.31 KB
title keywords f1_keywords ms.service ms.assetid ms.date ms.localizationpriority
Application.AlignTableCellVerticalCenter method (Project)
vbapj.chm1522
vbapj.chm1522
project-server
c790d8f7-e792-0718-3166-312640ff3f73
06/08/2017
medium

Application.AlignTableCellVerticalCenter method (Project)

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

Syntax

expression. AlignTableCellVerticalCenter

expression A variable that represents an Application object.

Return value

Boolean

Example

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
    theReport.Apply
    On Error GoTo 0
    
    For Each shp In theReport.Shapes
        Debug.Print "Shape: " & shp.Type & ", " & shp.Name
        
        If shp.HasTable Then
            shp.Select
            
            Select Case alignment
                Case "top"
                    AlignTableCellTop
                Case "center"
                    AlignTableCellVerticalCenter
                Case "bottom"
                    AlignTableCellBottom
                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

Report Object AlignTableCellTop Method AligntableCellBottom Method

[!includeSupport and feedback]