zoukankan      html  css  js  c++  java
  • 利用VBA把PowerDesigner的comment复制到name

    代码如下:

    Option   Explicit 
    '-------------------------------------------------------------------------------
    '作用:PowerDesigner物理模型复制comment到name
    '
    '作者: Lio5n
    '
    '时间: 2015-12-22
    '
    '版本: V2.0
    '
    '注意:如果name有值,将会覆盖;可以重复执行,不会多次复制
    '-------------------------------------------------------------------------------
    ValidationMode   = True 
    InteractiveMode  = im_Batch
    
    '----------------------------------请按需设置-----------------------------------
    
    CONST   CopyType = "ONE"            '执行模式 [ ONE-单表 ALL-所有表 ]
    CONST   TabCode  = "TabCode"        '单表模式下,表的Code
    CONST   ViewCode = "ViewCode"       '单表模式下,视图的Code
    
    '-------------------------------------------------------------------------------
    
    Dim   mdl   '当前模型
    Dim   Cnt   '处理个数
    Cnt = 0
    
    Set mdl = ActiveModel
    If ( mdl Is Nothing ) Then
      MsgBox "未找到活动的模型!"
    ElseIf Not mdl.IsKindOf(PdPDM.cls_Model) Then
      MsgBox "当前模型不是物理模型!"
    Else
      ProcessFolder mdl
      MsgBox "执行完成,共检索 [ " + CStr(Cnt) + " ] 张表!"
    End If
    
    Private Sub ProcessFolder(folder) 
      On Error Resume Next
    
        Dim Tab   '定义表
        For Each Tab In folder.tables
          If CopyType = "ONE" And UCase(Tab.code) <> UCase(TabCode) Then
          ElseIf Not Tab.isShortcut Then
            Cnt = Cnt + 1
            
            '表处理
            If Trim(Tab.comment) <> "" Then
              Tab.name = Trim(Tab.comment)
            End If
            
            '字段处理
            Dim Col
            For Each Col In Tab.columns
              If Trim(Col.comment) <> "" Then
                Col.name = Trim(Col.comment)
              End If
            Next
            
          End If
        Next
    
        '视图处理
        Dim View
        For Each View In folder.Views
          If CopyType = "ONE" And UCase(View.code) <> UCase(ViewCode) Then
          Else
            If Not View.isShortcut Then
              Cnt = Cnt + 1
              If Trim(View.comment) <> "" Then
                View.name = Trim(View.comment)
              End If
            End IF
          End If
        Next
        
        '进入子floder
        Dim f
        For Each f In folder.Packages
          If Not f.isShortcut Then
            ProcessFolder f
          End If
        Next
    
    End Sub
  • 相关阅读:
    耐性4/21
    吃枸杞上火4/11
    metro style app 的程序构成 以c# 为例 GIS
    ListView 和 GridView ————转 GIS
    最大程度地利用像素,适应视图状态的变更___转 GIS
    metro style 里面的控件一览 以 Windows.UI.Xaml.Controls空间 GIS
    Windows 8里的标准化输入 GIS
    漫游应用程序数据 GIS
    FlipView 知识准备 GIS
    Data Binding Notifications绑定通知 GIS
  • 原文地址:https://www.cnblogs.com/wanggs/p/5056916.html
Copyright © 2011-2022 走看看