Share via


HasText Property [Publisher 2003 VBA Language Reference]

HasText property as it applies to the Cell object.

Returns a Boolean value indicating whether the specified cell contains any text. True if the specified cell contains text. Read-only.

expression.HasText

expression Required. An expression that returns a Cell object.

HasText property as it applies to the TextFrame object.

MsoTriState

MsoTriState can be one of these MsoTriState constants.
msoCTrue Not used with this property.
msoFalse The specified shape does not have text associated with it.
msoTriStateMixed Not used with this property.
msoTriStateToggle Not used with this property.
msoTrue The specified shape has text associated with it.

expression.HasText

expression Required. An expression that returns a TextFrame object.

Example

As it applies to the Cell object.

If shape one on page one contains a table and the first cell of the table contains text, this example displays the text in a message box.

With ActiveDocument.Pages(1).Shapes(1)

    ' Check for table.
    If .HasTable Then
        With .Table.Cells(StartRow:=1, StartColumn:=1, _
                EndRow:=1, EndColumn:=1).Item(1)

            ' Check for text in first cell.
            If .HasText Then
                MsgBox "Text from first cell of table: " _
                    & vbCr & .Text
            Else
                MsgBox "No text in first cell."
            End If

        End With
    Else
        MsgBox "No table in shape one."
    End If

End With

As it applies to the TextFrame object.

If shape two on the first page of the active publication contains text, this example resizes the shape to fit the text.

With ActiveDocument.Pages(1).Shapes(2).TextFrame
    If .HasText Then .AutoFitText = pbTextAutoFitBestFit
End With

Applies to | Cell Object | TextFrame Object