Resource.Initials 属性 (Project)
获取或设置某一资源的缩写。 可读/写 String 类型。
语法
expression。 Initials
表达 一个代表 Resource 对象的变量。
示例
下面的示例将根据资源名称中的空格来设置活动项目中每一资源的缩写。 例如,一个名为"Glue Gun"的资源的缩写为"GG"。
Sub SetInitialsBasedOnName()
Dim I As Integer ' Index used in For loop
Dim R As Resource ' Resource used in For Each loop
Dim NewInits As String ' The new initials of the resource
' Cycle through the resources of the active project.
For Each R In ActiveProject.Resources
' Initialize with first character of name.
NewInits = Mid(R.Name, 1, 1)
' Look for spaces in the resource's name.
For I = 1 To Len(R.Name)
' If not first character, and space is found, then add initial.
If I > 1 And Mid(R.Name, I, 1) = Chr(32) Then
If I + 1 <= Len(R.Name) Then
NewInits = NewInits & Mid(R.Name, I + 1, 1)
End If
End If
Next I
' Give the resource its new initials.
R.Initials = NewInits
Next R
End Sub
支持和反馈
有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。