Text 属性

       

返回或设置指定对象的文本。对于 Range 对象,本属性为只读的 String 类型,对于其他对象,本属性为可读写的 String 类型。

有关在 Visual Basic 中使用 Text 工作表函数的详细信息,请参阅在 Visual Basic 中使用 Microsoft Excel 工作表函数

说明

对于 Phonetic 对象,本属性返回或设置其拼音形式的文本。不能将该属性设置为 Null

示例

本示例设置 Chart1 的图表标题文本。

With Charts("Chart1")
    .HasTitle = True
    .ChartTitle.Text = "First Quarter Sales"
End With

本示例设置 Chart1 中的分类轴标题文本。

With Charts("Chart1").Axes(xlCategory)
    .HasTitle = True
    .AxisTitle.Text = "Month"
End With

本示例演示包含格式数字的单元格的 TextValue 属性的不同用法。

Set c = Worksheets("Sheet1").Range("B14")
c.Value = 1198.3
c.NumberFormat = "$#,##0_);($#,##0)"
MsgBox c.Value
MsgBox c.Text