Table of contents

Resource.Initials 属性 (项目)Resource.Initials Property (Project)

office 365 dev account|上次更新日期: 2018/3/13
2 参与人员

获取或设置资源的缩写。读/写,字符串Gets or sets the initials of a resource. Read/write String.


表达式首字母缩写expression. Initials

表达式_一个表示资源对象的变量。_expression A variable that represents a Resource object.


下面的示例设置活动项目根据资源名称中的空格中的每个资源的缩写。例如,称为"粘附机枪"资源获得姓名首字母缩写"GG"。The following example sets the initials of each resource in the active project according to the spaces in the resource's name. For example, a resource called "Glue Gun" receives the initials "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
© 2018 Microsoft