转自
http://blog.sina.com.cn/s/blog_4a40fa550100aixu.html
贴到宏编辑器中执行即可。
'MACRO TITLE: Report Logical or Physical Model TO Microsoft Word
'This macro generates a mini report for the selected entities in the active model.
' REQUIREMENT: You must have Word 97 or later installed.
Sub Main
'Dim MS Word variables
Dim Word As Object
Dim Docs As Object
Dim ActiveDoc As Object
'Dim ER/Studio variables.
Dim diag As Diagram
Dim mdl As Model
Dim subMdl As SubModel
Dim ent As Entity
Dim attr As AttributeObj
Dim tableConstraints As TableCheckConstraints
Dim tableConstraint As TableCheckConstraint
Dim entNames As Variant
Dim entCount As Variant
Dim entLoop As Integer
'Start MS Word and make it visible.
Set Word = CreateObject("Word.Application")
Wait 1 'Wait 1 second to allow application to be instantiated
Word.Visible = True
Word.Documents.Add
Set ActiveDoc = Word.Documents(1)
ActiveDoc.Activate
With ActiveDoc
.ShowSpellingErrors = False
.ShowGrammaticalErrors = False
With .pageSetup
.LeftMargin = 0.5*72 'Points
.RightMargin = 0.5*72
.TopMargin = 0.5*72
.BottomMargin = 0.5*72
End With
End With
'Init the ER/Studio variables.
Set diag = DiagramManager.ActiveDiagram
Set mdl = diag.ActiveModel
'Process the current submodel, if one exists
Set subMdl=mdl.ActiveSubModel
subMdl.EntityNames(entNames, entCount)
'Sort the entity names
Call dhQuickSort(entNames)
'Iterate through all entities in the current sub-model
For entLoop = 0 To entCount - 1 'For Each ent In subMdl.Entities()
Set ent = mdl.Entities.Item(entNames(entLoop))
With Word.Selection
'First the entity name
.Font.Bold = True
.Font.Underline = True
.Font.Size = 18
.TypeText Text:=ent.TableName
'Keep the paragraph together, and with the next paragraph
.Paragraphs(1).KeepTogether = True
.Paragraphs(1).KeepWithNext = True
'Now the entity definition
.Font.Underline = False
.Font.Bold = False
.Font.Size = 12
.TypeText Text:=" " & ent.Definition & vbCrLf
'Is there a check constraint?
Set tableConstraints = ent.TableCheckConstraints
For Each tableConstraint In tableConstraints
.TypeText Text:="Constraint " _
& tableConstraint.ConstraintName _
& ": " & tableConstraint.ConstraintText & vbCrLf
Next
End With
'Iterate through all the attributes in the current entity
For Each attr In ent.Attributes
With Word.Selection
'First the attribute name
.Font.Bold = True
'Check for a rolename
If attr.AttributeName<>attr.ColumnName Then
.TypeText Text:=attr.ColumnName & "." & attr.AttributeName & ": "
Else
.TypeText Text:=attr.ColumnName & ": "
End If
.Font.Bold = False
'Then the datatype
'.TypeText Text:= attr.Datatype
.typetext Text:= attr.PhysicalDatatype
If attr.DataLength > 0 Then
.TypeText Text:= "(" & attr.DataLength & ")"
End If
.TypeText Text:= ": "
'Now the Null option and Definition
.TypeText Text:= IIf(attr.Identity, "IDENTITY", attr.NullOption) & ": " & attr.Definition & vbCrLf
'Is there a default value?
If Len(attr.DeclaredDefault) > 0 Then
.TypeText Text:= " Default Value: " & attr.DeclaredDefault & vbCrLf
End If
'Is there a validation rule?
If Len(attr.CheckConstraint) > 0 Then
.TypeText Text:= " Constraint " & attr.CheckConstraintName _
& ": " & attr.CheckConstraint & vbCrLf
End If
End With
Next
With Word.Selection
.Paragraphs(1).KeepWithNext = False
.TypeText Text:= vbCrLf
End With
Next
End Sub
' **The following code is taken from the specified book. It has been modified
' **to perform a case insensitive sort.
' From "VBA Developer's Handbook"
' by Ken Getz and Mike Gilbert
' Copyright 1997; Sybex, Inc. All rights reserved.
' Quicksort for simple data types.
' Indicate that a parameter is missing.
Const dhcMissing = -2
Sub dhQuickSort(varArray As Variant, _
Optional intLeft As Integer = dhcMissing, _
Optional intRight As Integer = dhcMissing)
' From "VBA Developer's Handbook"
' by Ken Getz and Mike Gilbert
' Copyright 1997; Sybex, Inc. All rights reserved.
' Entry point for sorting the array.
' This technique uses the recursive Quicksort
' algorithm to perform its sort.
' In:
' varArray:
' A variant pointing to an array to be sorted.
' This had better actually be an array, or the
' code will fail, miserably. You could add
' a test for this:
' If Not IsArray(varArray) Then Exit Sub
' but hey, that would slow this down, and it's
' only YOU calling this procedure.
' Make sure it's an array. It's your problem.
' intLeft:
' intRight:
' Lower and upper bounds of the array to be sorted.
' If you don't supply these values (and normally, you won't)
' the code uses the LBound and UBound functions
' to get the information. In recursive calls
' to the sort, the caller will pass this information in.
' To allow for passing integers around (instead of
' larger, slower variants), the code uses -2 to indicate
' that you've not passed a value. This means that you won't
' be able to use this mechanism to sort arrays with negative
' indexes, unless you modify this code.
' Out:
' The data in varArray will be sorted.
Dim i As Integer
Dim j As Integer
Dim varTestVal As Variant
Dim intMid As Integer
If intLeft = dhcMissing Then intLeft = LBound(varArray)
If intRight = dhcMissing Then intRight = UBound(varArray)
If intLeft < intRight Then
intMid = (intLeft + intRight) \ 2
varTestVal = UCase(varArray(intMid))
i = intLeft
j = intRight
Do
Do While UCase(varArray(i)) < varTestVal
i = i + 1
Loop
Do While UCase(varArray(j)) > varTestVal
j = j - 1
Loop
If i <= j Then
SwapElements varArray, i, j
i = i + 1
j = j - 1
End If
Loop Until i > j
' To optimize the sort, always sort the
' smallest segment first.
If j <= intMid Then
Call dhQuickSort(varArray, intLeft, j)
Call dhQuickSort(varArray, i, intRight)
Else
Call dhQuickSort(varArray, i, intRight)
Call dhQuickSort(varArray, intLeft, j)
End If
End If
End Sub
Private Sub SwapElements(varItems As Variant, intItem1 As Integer, intItem2 As Integer)
Dim varTemp As Variant
varTemp = varItems(intItem2)
varItems(intItem2) = varItems(intItem1)
varItems(intItem1) = varTemp
End Sub
相关推荐
ERstudio宏可以帮助我们跟据对象生成我们想要的文件.
本人修改的ERStudio输出word文档格式最友好的宏,格式友好 自动排序,加入章节(根据子submodal模型),页码,索引,加入目录,文档时间等等
ERStudio8能够自动生成详细的数据库设计文档,包括ER图、关系矩阵、SQL脚本等,便于团队协作和知识共享。 7. **版本控制**: 支持与常见版本控制系统集成,如Git,使得多用户协同工作更为顺畅,同时追踪模型的...
ERstudio2020版。将patch.exe放到安装目录,断网,然后依次点击patch和license进行操作。
ERStudio8注册工具,ER/Studio Data Architect (ER/Studio DA)是一种可视化数据建模工具,它不仅可以用于设计并构建个别平台的物理数据库,还可以对不同平台上的逻辑数据架构进行分析和设计。
ERStudio.v8.0.2.5991的破解文件 查看dm1格式文件
这个是erstudio的破解补丁,复制到erstudio安装目录下,运行,点击“apply patch”即可
ERStudio是一款强大的数据库建模工具,它被广泛用于设计、管理和理解复杂的数据库结构。这款工具提供了数据建模、数据仓库建模以及元数据管理等多种功能,帮助IT专业人员高效地进行数据库开发和管理。 首先,我们来...
- 对于**开发人员**,ERStudio提供了一套完整的代码生成工具,可以自动生成SQL脚本等,加快了开发速度。 - **评估指南概览**:本评估指南旨在帮助用户快速了解ERStudio的核心功能和使用方法。 #### 二、课程1:...
打开ers80——5910.exe进行安装 安装过程中username那一步操作可以随便填入不影响后续使用 安装完成后 将patch.exe放入ERStudio的根目录运行后点击一次"apply"界面显示ok即可关闭 完美运行ERStudio
自己写的复制ERStudio中的逻辑名称到definition中,包括表名和字段名,这样在生成sql脚本的时候可以直接生成comments了。
erstudio软件,无需破解可安装。不需要破解文件就可以直接安装
ERStudio8.0-带注册机-仅供个人学习 patch_setup.exe 文件拷贝到安装目录,然后执行,点击注册即可。
erstudio8.0破解版,含注册机,亲测,好用。
使用ERStudio,你可以设计针对SQL Server的数据库模型,并直接生成相应的SQL脚本来创建或修改数据库,大大简化了数据库开发流程。 ERStudio8.0可能包含以下特性: 1. **可视化建模**:提供直观的图形界面,用户可以...
ERStudio 汉化 破解版 V8.0 可以用 绿色。。。。。。。。。。。。。。。1213123213213213
标题中的"ER Studio 7.0 Key Generator"指的是该软件的一个版本——第七版的密钥生成器,这通常是为了激活软件的全功能而使用的。 ER设计是数据库设计过程中的关键步骤,它帮助开发者理解和可视化数据之间的关系。...
Embarcadero ERStudio.v8.0.2.5991 Crack 数据模型工具 制作ER图 part1
ERStudio.v8.0.0.5910 破解程序