---转载之hp的官方论坛
'Script for copying a public favorite to all other projects
'Jan Czajkowski, jan.czajkowski@sqs-nordic.com, Aug. 25 2009
Function getCommonSetting(aTdc, category, settingName)
Set cs = aTdc.CommonSettings
cs.Open category
getCommonSetting = cs.Value(settingName)
cs.Close
Set cs = Nothing
End Function
Sub setCommonSetting(aTdc, category, settingName, value)
Set cs = aTdc.CommonSettings
cs.Open category
cs.Value(settingName) = value
cs.Close
Set cs = Nothing
End Sub
Sub copyFavorite (category, favoriteName)
'Get the contents of the favorite you want to copy
tdc.Connect sourceDomain, sourceProject
templateSettingValue = getCommonSetting(tdc, category, favoriteName)
tdc.Disconnect
Set domainList = tdc.VisibleDomains
For Each dom in domainList
For Each proj In tdc.VisibleProjects(dom)
If proj <> sourceProject Then
tdc.Connect dom, proj
setCommonSetting tdc, category, favoriteName, templateSettingValue
f.WriteLine proj & ": Copied common setting " & favoriteName
tdc.Disconnect
End If
Next
Next
Set domainList = Nothing
End Sub
'Log your progress to a file
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("c:/LoggingFavorites.txt", 2, True)
password = InputBox("Password:")
user = InputBox("User name:")
server = "http://YourQCServer:8080/qcbin"
sourceDomain = "YourDomain"
sourceProject = "YourProject"
Set tdc = CreateObject("tdapiole80.tdconnection")
tdc.InitConnectionEx (server)
tdc.Login user, password
copyFavorite "Category", "A public favorite"
copyFavorite "AnotherCategory", "Another public favorite"
tdc.ReleaseConnection
f.Close
msgbox "Finished copying favorites"
本文介绍了一段VBA脚本,该脚本可以用于将一个项目的公共设置(如收藏夹配置)复制到其他多个项目中。通过连接到目标服务器,并遍历所有可见域和项目,脚本能够确保所有指定的目标项目都应用了相同的公共设置。
2417

被折叠的 条评论
为什么被折叠?



