天天看點

PowerDesigner 中将Comment(注釋)及Name(名稱)内容互相COPY的VBS代碼

在用PowerDesigner時.常常在NAME或Comment中寫中文在Code中寫英文.Name隻會顯示給我們看,Code會使用在代碼中.但Comment中的文字會儲存到資料庫TABLE的Description中,有時候我們寫好了Name再寫一次Comment很麻煩.以下兩段代碼就可以解決這個問題.

代碼一:将Name中的字元COPY至Comment中

使用菜單:"Tools->Execute Commands->Edit/Run Scripts"來執行下面腳本

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代碼
PowerDesigner 中将Comment(注釋)及Name(名稱)内容互相COPY的VBS代碼
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代碼
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代碼
PowerDesigner 中将Comment(注釋)及Name(名稱)内容互相COPY的VBS代碼
PowerDesigner 中将Comment(注釋)及Name(名稱)内容互相COPY的VBS代碼
PowerDesigner 中将Comment(注釋)及Name(名稱)内容互相COPY的VBS代碼
PowerDesigner 中将Comment(注釋)及Name(名稱)内容互相COPY的VBS代碼
PowerDesigner 中将Comment(注釋)及Name(名稱)内容互相COPY的VBS代碼
PowerDesigner 中将Comment(注釋)及Name(名稱)内容互相COPY的VBS代碼
PowerDesigner 中将Comment(注釋)及Name(名稱)内容互相COPY的VBS代碼
PowerDesigner 中将Comment(注釋)及Name(名稱)内容互相COPY的VBS代碼
PowerDesigner 中将Comment(注釋)及Name(名稱)内容互相COPY的VBS代碼
PowerDesigner 中将Comment(注釋)及Name(名稱)内容互相COPY的VBS代碼
PowerDesigner 中将Comment(注釋)及Name(名稱)内容互相COPY的VBS代碼
PowerDesigner 中将Comment(注釋)及Name(名稱)内容互相COPY的VBS代碼
PowerDesigner 中将Comment(注釋)及Name(名稱)内容互相COPY的VBS代碼
PowerDesigner 中将Comment(注釋)及Name(名稱)内容互相COPY的VBS代碼
PowerDesigner 中将Comment(注釋)及Name(名稱)内容互相COPY的VBS代碼
PowerDesigner 中将Comment(注釋)及Name(名稱)内容互相COPY的VBS代碼
PowerDesigner 中将Comment(注釋)及Name(名稱)内容互相COPY的VBS代碼

On Error Resume Next

PowerDesigner 中将Comment(注釋)及Name(名稱)内容互相COPY的VBS代碼
PowerDesigner 中将Comment(注釋)及Name(名稱)内容互相COPY的VBS代碼
PowerDesigner 中将Comment(注釋)及Name(名稱)内容互相COPY的VBS代碼
PowerDesigner 中将Comment(注釋)及Name(名稱)内容互相COPY的VBS代碼

                  tab.name   =   tab.comment

PowerDesigner 中将Comment(注釋)及Name(名稱)内容互相COPY的VBS代碼
PowerDesigner 中将Comment(注釋)及Name(名稱)内容互相COPY的VBS代碼
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代碼
PowerDesigner 中将Comment(注釋)及Name(名稱)内容互相COPY的VBS代碼
PowerDesigner 中将Comment(注釋)及Name(名稱)内容互相COPY的VBS代碼
PowerDesigner 中将Comment(注釋)及Name(名稱)内容互相COPY的VBS代碼
PowerDesigner 中将Comment(注釋)及Name(名稱)内容互相COPY的VBS代碼
PowerDesigner 中将Comment(注釋)及Name(名稱)内容互相COPY的VBS代碼
PowerDesigner 中将Comment(注釋)及Name(名稱)内容互相COPY的VBS代碼
PowerDesigner 中将Comment(注釋)及Name(名稱)内容互相COPY的VBS代碼

                  view.name   =   view.comment 

PowerDesigner 中将Comment(注釋)及Name(名稱)内容互相COPY的VBS代碼
PowerDesigner 中将Comment(注釋)及Name(名稱)内容互相COPY的VBS代碼
PowerDesigner 中将Comment(注釋)及Name(名稱)内容互相COPY的VBS代碼
PowerDesigner 中将Comment(注釋)及Name(名稱)内容互相COPY的VBS代碼
PowerDesigner 中将Comment(注釋)及Name(名稱)内容互相COPY的VBS代碼
PowerDesigner 中将Comment(注釋)及Name(名稱)内容互相COPY的VBS代碼
PowerDesigner 中将Comment(注釋)及Name(名稱)内容互相COPY的VBS代碼
PowerDesigner 中将Comment(注釋)及Name(名稱)内容互相COPY的VBS代碼
PowerDesigner 中将Comment(注釋)及Name(名稱)内容互相COPY的VBS代碼
PowerDesigner 中将Comment(注釋)及Name(名稱)内容互相COPY的VBS代碼
PowerDesigner 中将Comment(注釋)及Name(名稱)内容互相COPY的VBS代碼