前言:由于一次失误,导致根据Excel模板生成表结构name和code值反了,又使用一个脚本进行更换
一、表结构示例:
二、脚本(推荐保存为".vbs"的文档)
Option Explicit
ValidationMode = True
InteractiveMode = im_Batch
Dim mdl 'the current model
'get the current active model
Set mdl = ActiveModel
If (mdl Is Nothing) Then
MsgBox "There is no current Model"
ElseIf Not mdl.IsKindOf(PdPDM.cls_Model) Then
MsgBox "The current model is not an Physical Data model."
Else
ProcessFolder mdl
End If
'This routine copy name into code for each table, each column and each view
'of the current folder
Private sub ProcessFolder(folder)
Dim Tab 'running table
for each Tab in folder.tables
if not tab.isShortcut then
if len(tab.code) <> 0 then
tab.name = tab.code
end if
On Error Resume Next
Dim col 'running column
dim w
for each col in tab.columns
if len(col.code) <>0 then
w=col.name
col.name =col.code
col.code=w
end if
On Error Resume Next
next
end if
next
end sub
三、运行脚本,效果如下
注意:点击运行之后会把工作空间中所有表的NAME与CODE值互换,且表名NAME变更为与CODE值相同,这个需要提前记一下表名,以免忘记。