' MACRO TITLE: CONVERT CASE NAME ' AUTHOR: Mervyn Courtney ' DATE: 30/10/2003 ' This macro converts the case of Attributes, Columns and Entty/Table names for the highlighted tables/Entities ' in the active SubModel to all upper or lower case. Works in Logical or Physical models Sub Main ' Declare the variables. Dim d As Diagram Dim m As Model Dim sm As SubModel Dim o As SelectedObject Dim id As Integer Dim e As Entity Dim a As AttributeObj ' Do the normal stuff. Set d = DiagramManager.ActiveDiagram Set m = d.ActiveModel Set sm = m.ActiveSubModel ' Prompt the user to make a choice for upper/lower case. Begin Dialog UserDialog 300,112,"Case Selection" ' %GRID:10,7,1,1 OKButton 110,91,90,21 GroupBox 10,7,140,77,"Convert",.GroupBox1 CheckBox 20,21,110,14,"Entity/Table",.chkEntity CheckBox 20,42,100,14,"Columns",.chkColumn CheckBox 20,63,90,14,"Attributes",.chkAttr GroupBox 160,7,130,77,"Case Conversion",.GroupBox2 OptionGroup .optCase OptionButton 170,28,100,14,"&Upper Case",.OptionButton1 OptionButton 170,49,100,14,"&Lower Case",.OptionButton2 End Dialog Dim dlg As UserDialog Dialog dlg ' You need the submodel when determining what's selected. ' Iterate through all selected objects and process the only entities. For Each o In sm.SelectedObjects If o.Type = 1 Then ' Entities are Type 1 objects. ' Get the entity. id = o.ID Set e = m.Entities.Item(id) ' Make the conversion. If dlg.optCase = 0 Then If dlg.chkEntity = 1 Then e.EntityName = StrConv(e.EntityName, vbUpperCase) e.TableName = StrConv(e.TableName, vbUpperCase) End If If dlg.chkColumn = 1 Then For Each a In e.Attributes a.ColumnName =StrConv(a.ColumnName,vbUpperCase) Next End If If dlg.chkAttr = 1 Then For Each a In e.Attributes a.AttributeName =StrConv(a.AttributeName,vbUpperCase) Next End If ElseIf dlg.optCase = 1 Then If dlg.chkEntity = 1 Then e.EntityName = StrConv(e.EntityName, vbLowerCase) e.TableName = StrConv(e.TableName, vbLowerCase) End If If dlg.chkColumn = 1 Then For Each a In e.Attributes a.ColumnName =StrConv(a.ColumnName,vbLowerCase) Next End If If dlg.chkAttr = 1 Then For Each a In e.Attributes a.AttributeName =StrConv(a.AttributeName,vbLowerCase) Next End If End If End If Next End Sub