MS项目在资源使用视图中导航资源和作业

发布于 2025-01-30 05:12:14 字数 470 浏览 1 评论 0原文

问候。我正在寻找VBA中的代码,该代码允许我在资源使用视图中使用for Next在ResourceField中进行分配的资源,并从TimesCalerange中提取他们的作业信息(右图带有表格信息),in为了能够格式化信息并在决策后导出。

捕获资源用法的捕获视图

”在此处输入图像描述”

我将关注的信息扩展了一点...在捕获中,我呈现资源使用视图,我获取这些信息,并在左侧使用资源列表,我将其复制并粘贴在Excel中;有了这些信息,我创建了我的资源直方图,但是我想通过VBA宏来生成导出过程,因为有几个步骤可以执行(过滤,组织视图的时间表以及导出开始到终点的信息)。

Regards. I am looking for a code in VBA that allows me, in the RESOURCE USAGE view, to go through the resources with assignment in the ResourceField with a FOR NEXT, and extract their assignment information from the TimescaleRange (right panel with tabular information), in order to be able to format the information and export it upon decision.

Capture of the RESOURCE USAGE view

enter image description here

I expand a little the information of my concern... in the capture I present the Resource Usage view, I take that information and with the list of resources on the left, I copy and paste it in excel; With this information I create my resource histogram, but I want to generate the export process through a VBA macro since there are several steps to perform (filtering, organizing the timeline of the view, and exporting the information of start to finish).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

旧伤还要旧人安 2025-02-06 05:12:14

该代码将循环通过活动项目中的资源,并按每周逐日获取工作时间。

Sub GetWorkByResourceByAssignment()

    Dim dteStart As Date
    Dim dteEnd As Date

    dteStart = #5/24/2021#
    dteEnd = #8/2/2021#
    
    Dim res As Resource
    Dim a As Assignment
    Dim tsvs As TimeScaleValues
    Dim tsv As TimeScaleValue
    
    For Each res In ActiveProject.Resources
        For Each a In res.Assignments
    
            Set tsvs = a.TimeScaleData(StartDate:=dteStart, _
                                       EndDate:=dteEnd, _
                                       Type:=pjAssignmentTimescaledWork, _
                                       TimeScaleUnit:=pjTimescaleWeeks)
            ReDim workHours(tsvs.Count) As Long
            Dim strValues As String
            strValues = vbNullString
            Dim i As Integer
            i = 0
            For Each tsv In tsvs
                i = i + 1
                workHours(i) = Val(tsv.Value) / 60
                strValues = strValues & ", " & workHours(i)
            Next tsv
            Debug.Print res.Name, a.Task.Name, strValues
        Next
    Next
    
End Sub

变量strvalues和调试语句用于演示目的。数组workHours包含可用于直方图的小时的数字表示。

This code will loop through the resources in the active project and get work hours by resource by week.

Sub GetWorkByResourceByAssignment()

    Dim dteStart As Date
    Dim dteEnd As Date

    dteStart = #5/24/2021#
    dteEnd = #8/2/2021#
    
    Dim res As Resource
    Dim a As Assignment
    Dim tsvs As TimeScaleValues
    Dim tsv As TimeScaleValue
    
    For Each res In ActiveProject.Resources
        For Each a In res.Assignments
    
            Set tsvs = a.TimeScaleData(StartDate:=dteStart, _
                                       EndDate:=dteEnd, _
                                       Type:=pjAssignmentTimescaledWork, _
                                       TimeScaleUnit:=pjTimescaleWeeks)
            ReDim workHours(tsvs.Count) As Long
            Dim strValues As String
            strValues = vbNullString
            Dim i As Integer
            i = 0
            For Each tsv In tsvs
                i = i + 1
                workHours(i) = Val(tsv.Value) / 60
                strValues = strValues & ", " & workHours(i)
            Next tsv
            Debug.Print res.Name, a.Task.Name, strValues
        Next
    Next
    
End Sub

The variable strValues and the debug statement are for demonstration purposes. The array workHours contains the numeric representation of the hours which can be used for the histogram.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文