Skip to content

Latest commit

 

History

History
65 lines (40 loc) · 1.59 KB

Project.Resource.MaterialLabel.md

File metadata and controls

65 lines (40 loc) · 1.59 KB
title ms.service api_name ms.assetid ms.date ms.localizationpriority
Resource.MaterialLabel property (Project)
project-server
Project.Resource.MaterialLabel
802fd00b-3f0e-9ecf-6cb9-a8858f0137a0
06/08/2017
medium

Resource.MaterialLabel property (Project)

Gets or sets the label for a material resource. Read/write String.

Syntax

expression. MaterialLabel

expression A variable that represents a Resource object.

Remarks

The MaterialLabel property does not return any meaningful information for non-material resources, such as people or machines. Setting a value returns a trappable error (error code 1101) when applied to non-material resources.

Example

This example goes through the list of resources in the current project and sets the material label for all material resources to "pallet." (The error trapping in this example is only to illustrate how you might handle an expected exception. In a real-life example, you would probably include a test such as the following:

If InStr(R.Name, "bricks") <> 0 Then...

The test would ensure that you only assign the material label to paving bricks, red bricks, and so on.

Sub FixLabels() 
 Dim R As Resource 
 
 On Error GoTo ErrTrap: 
 
 For Each R In ActiveProject.Resources 
 If R.MaterialLabel <> "pallet" Then R.MaterialLabel = "pallet" 
 Next R 
 
 Exit Sub 
 
ErrTrap: 
 If Err.Number = 1101 Then 
 Err.Clear 
 Resume Next 
 Else 
 MsgBox Err.Description, vbExclamation, "Error" 
 End If 
End Sub

[!includeSupport and feedback]