我们使用 Microsoft 默认提供的 MSF Agile 5.0 流程模板来运行我们的项目。具体来说,迭代待办事项列表 Excel 表格对于进行项目管理非常有用。
然而,我们遇到过第 1 个工作表上的迭代待办事项列表不是最新的情况。打开 Excel 工作簿后,用户必须明确地单击“团队”选项卡上的“刷新”按钮即可查看最新数据。
问题:我们如何强制 Excel (2007) 在打开工作簿时刷新迭代待办事项列表并与其连接到的 TFS 2010 工作项查询同步?
其他人提供的记录宏以单击“刷新”按钮的建议不起作用,因为记录的宏无法刷新具有树层次结构的查询(至少,执行宏时发生错误告诉我)。录制的宏可以执行其他操作,只需单击按钮:-)
MSDN 库中有关列表类型的一些入门知识
列表类型
将输入列表转换为查询列表
现在谈谈手头的问题。
正如前面的回答者所说,您需要从工作簿打开事件运行的代码。我相信这部分你已经知道了。
刷新方法是通用的,仅适用于数据连接、公式和常规共享点列表。
您需要使用功能区中的团队菜单。
以下代码片段显示了如何获取表示保存工作项数据的表的列表对象的方法。
通过VBA同步TFS和Excel
如果链接中断,则部分复制代码如下(只需激活团队菜单)。他们文章中的 MSDN 链接看起来已经损坏(或者可能没有..)
Private Function FindTeamControl(tagName As String) As CommandBarControl
Dim commandBar As commandBar
Dim teamCommandBar As commandBar
Dim control As CommandBarControl
For Each commandBar In Application.CommandBars
If commandBar.Name = "Team" Then
Set teamCommandBar = commandBar
Exit For
End If
Next
If Not teamCommandBar Is Nothing Then
For Each control In teamCommandBar.Controls
If InStr(1, control.Tag, tagName) Then
Set FindTeamControl = control
Exit Function
End If
Next
End If
End Function
Sub RefreshTeamQuery(shtTFSExcel_Name As String) '(rangeName As String)
Dim activeSheet As Worksheet
Dim teamQueryRange As Range
Dim refreshControl As CommandBarControl
Set refreshControl = FindTeamControl("IDC_REFRESH")
If refreshControl Is Nothing Then
MsgBox "Could not find Team Foundation commands in Ribbon. Please make sure that the Team Foundation Excel plugin is installed.", vbCritical
Exit Sub
End If
End Sub
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)