获取表示活动单元格中资源的 资源 对象。 只读的 资源 。
语法
expression。 Resource
表达 一个代表 Cell 对象的变量。
示例
以下示例将"资源的工作完成情况"分组应用于"资源工作表"视图,然后选择视图中每一行的第一个单元格并测试该行是否是分组摘要。 此过程将继续,直到行为空为止,然后显示一个带有每行测试结果的消息框。
Sub ShowGroupByItems()
Dim isValid As Boolean
Dim res As Resource
Dim rowType As String
Dim msg As String
isValid = True
msg = ""
ActiveProject.Views("Resource Sheet").Apply
GroupApply Name:="Complete and Incomplete Resources"
Application.SelectBeginning
' When a cell in an empty row is selected, accessing the ActiveCell.Resource
' property results in error 1004.
On Error Resume Next
' Loop until a cell in an empty row is selected.
While isValid
Set res = ActiveCell.Resource
If Err.Number > 0 Then
isValid = False
Debug.Print Err.Number
Err.Number = 0
Else
If res.GroupBySummary Then
rowType = "' is a group-by summary row."
Else
rowType = "' is a resource row."
End If
msg = msg & "Resource name: '" & res.Name & rowType & vbCrLf
SelectCellDown
End If
Wend
MsgBox msg, vbInformation, "GroupBy Summary for Resources"
End Sub
支持和反馈
有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。