(You edit macro code using the code editor just as you would to edit any other document with Visual Studio.) To rework this macro, you can start by establishing a recursive helper routine that takes in a UIHierarchyItem object, toggles its Expanded property to True, and calls itself for each sub item found in the UIHierarchyItems collection:
(
For Each subNode As UIHierarchyItem In node.UIHirerarchyItems
ExpandNodes(subNode)
Next
node.UIHierarchyItems.Expanded = True
)
【说明】括号中为辅助理解。文中并没有给出递归程序的签名,但是很容易猜出应该是:Sub ExpandNodes(UIHierarchyItem node)。
【难点】如何组织成符合汉语习惯的语序。
【目前翻译】(使用宏代码编辑器编辑宏和在Visual Studio中编辑其他文档的方式没什么两样。)回到刚才的宏,首先你可以创建一个递归的助手(工具??)程序,在这个程序以UIHierarchyItem对象为参数(后面未贴出的部分代码中显示确实将UIHierarchyItem作为参数,这里作者使用take in,也暗示了这一点),把它的Expanded属性(译者注:实际上是它的子项的集合UIHierarchyItems的属性)设置为True,并且对其子项集合UIHierarchyItems中的每一项(译者注:也是UIHierarchyItem)递归的调用这个程序。