在用PowerDesigner时.常常在NAME或Comment中写中文在Code中写英文.Name只会显示给我们看,Code会使用在代码中.但Comment中的文字会保存到数据库TABLE的Description中,有时候我们写好了Name再写一次Comment很麻烦.以下两段代码就可以解决这个问题.
代码一:将Name中的字符COPY至Comment中

PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码
'****************************************************************************** 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码'
*   File:           name2comment.vbs 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码'
*   Purpose:     Database   generation   cannot   use   object   names   anymore   
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码'
                         in   version   7   and   above. 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码'
                         It   always   uses   the   object   codes. 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码'
 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码'
                         In   case   the   object   codes   are   not   aligned   with   your   
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码'
                         object   names   in   your   model,   this   script   will   copy   
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码'
                         the   object   Name   onto   the   object   Comment   for   
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码'
                         the   Tables   and   Columns. 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码'
 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码'
*   Title:         
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码'
*   Version:     1.0 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码'
*   Company:     Sybase   Inc.   
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码'
****************************************************************************** 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码

PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码
Option   Explicit 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码ValidationMode   
=   True 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码InteractiveMode   
=   im_Batch 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码
Dim   mdl   '   the   current   model 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码

PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码
'   get   the   current   active   model 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码
Set   mdl   =   ActiveModel 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码
If   (mdl   Is   Nothing)   Then 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码      
MsgBox   "There   is   no   current   Model " 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码
ElseIf   Not   mdl.IsKindOf(PdPDM.cls_Model)   Then 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码      
MsgBox   "The   current   model   is   not   an   Physical   Data   model. " 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码
Else 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码      ProcessFolder   mdl 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码
End   If 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码
'   This   routine   copy   name   into   comment   for   each   table,   each   column   and   each   view 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码'
   of   the   current   folder 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码
Private   sub   ProcessFolder(folder) 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码      
Dim   Tab   'running     table 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码
      for   each   Tab   in   folder.tables 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码            
if   not   tab.isShortcut   then 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码                  tab.comment   
=   tab.name 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码                  
Dim   col   '   running   column 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码
                  for   each   col   in   tab.columns 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码                        col.comment
=   col.name 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码                  
next 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码            
end   if 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码      
next 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码      
Dim   view   'running   view 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码
      for   each   view   in   folder.Views 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码            
if   not   view.isShortcut   then 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码                  view.comment   
=   view.name 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码            
end   if 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码      
next 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码      
'   go   into   the   sub-packages 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码
      Dim   f   '   running   folder 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码
      For   Each   f   In   folder.Packages 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码            
if   not   f.IsShortcut   then 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码                  ProcessFolder   f 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码            
end   if 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码      
Next 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码
end   sub
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码

代码二:将Comment中的字符COPY至Name中

PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码Option   Explicit 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码ValidationMode   
=   True 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码InteractiveMode   
=   im_Batch 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码
Dim   mdl   '   the   current   model 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码

PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码
'   get   the   current   active   model 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码
Set   mdl   =   ActiveModel 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码
If   (mdl   Is   Nothing)   Then 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码      
MsgBox   "There   is   no   current   Model " 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码
ElseIf   Not   mdl.IsKindOf(PdPDM.cls_Model)   Then 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码      
MsgBox   "The   current   model   is   not   an   Physical   Data   model. " 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码
Else 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码      ProcessFolder   mdl 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码
End   If 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码
Private   sub   ProcessFolder(folder) 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码
On Error Resume Next
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码      
Dim   Tab   'running     table 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码
      for   each   Tab   in   folder.tables 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码            
if   not   tab.isShortcut   then 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码                  tab.name   
=   tab.comment
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码                  
Dim   col   '   running   column 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码
                  for   each   col   in   tab.columns 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码                  
if col.comment="" then
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码                  
else
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码                        col.name
=   col.comment 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码                  
end if
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码                  
next 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码            
end   if 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码      
next 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码      
Dim   view   'running   view 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码
      for   each   view   in   folder.Views 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码            
if   not   view.isShortcut   then 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码                  view.name   
=   view.comment 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码            
end   if 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码      
next 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码      
'   go   into   the   sub-packages 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码
      Dim   f   '   running   folder 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码
      For   Each   f   In   folder.Packages 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码            
if   not   f.IsShortcut   then 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码                  ProcessFolder   f 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码            
end   if 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码      
Next 
PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码
end   sub

相关文章: