Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/hadoop/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
迭代资源图视图,并在VBA Microsoft Project 2010中使用资源名称导出到XPS_Vba_Ms Office_Ms Project - Fatal编程技术网

迭代资源图视图,并在VBA Microsoft Project 2010中使用资源名称导出到XPS

迭代资源图视图,并在VBA Microsoft Project 2010中使用资源名称导出到XPS,vba,ms-office,ms-project,Vba,Ms Office,Ms Project,我正在尝试遍历资源图,每次查看一个资源,并使用与文件关联的适当名称导出到XPS。 代码如下: Sub ResourcGraph() ' Macro Macro4 ' Macro Recorded Tue 6/9/15 by Valencia, Jonathan. Dim Res As Resource ViewApply "Resource Graph" SelectBeginning For Each Res In ActiveProject.Resources If Not R

我正在尝试遍历资源图,每次查看一个资源,并使用与文件关联的适当名称导出到XPS。 代码如下:

Sub ResourcGraph()
' Macro Macro4
' Macro Recorded Tue 6/9/15 by Valencia, Jonathan.


Dim Res As Resource
ViewApply "Resource Graph"

SelectBeginning
For Each Res In ActiveProject.Resources
    If Not Res Is Nothing Then
    DocumentExport FileName:=Res.Name & "Graph", FileType:=pjXPS
    End If
    SelectCellRight
Next Res




End Sub

这段代码可以很好地进行迭代。我遇到的问题是名称是否正确。该文件由资源命名,但当我单击该文件时,它是错误的资源。有没有一种方法可以从资源图视图中提取活动资源的信息,而不是像我现在这样浏览资源?

这可能是因为资源图的排序顺序与资源集合中的资源不同。您可以使用Find命令将图形移动到正确的资源,而不是尝试同步这些资源

Sub ResourcGraph()

Dim Res As Resource
ViewApply "Resource Graph"

For Each Res In ActiveProject.Resources
    If Not Res Is Nothing Then
        FindEx Field:="Name", Test:="equals", Value:=Res.name, Next:=True
        DocumentExport FileName:=Res.name & "Graph", FileType:=pjXPS
    End If
Next Res

End Sub

这可能是因为资源图的排序顺序与资源集合中的资源不同。您可以使用Find命令将图形移动到正确的资源,而不是尝试同步这些资源

Sub ResourcGraph()

Dim Res As Resource
ViewApply "Resource Graph"

For Each Res In ActiveProject.Resources
    If Not Res Is Nothing Then
        FindEx Field:="Name", Test:="equals", Value:=Res.name, Next:=True
        DocumentExport FileName:=Res.name & "Graph", FileType:=pjXPS
    End If
Next Res

End Sub

我甚至没有想到find函数。它就像一个符咒!!我甚至没有想到find函数。它就像一个符咒!!我甚至没有想到find函数。它就像一个符咒!!