Welcome to ModelRight Database Design Tool - Database Modeling Done Right Sign in | Join | Help

How to export ModelRight info to Excel

File Details
Downloads: 344 File Size: 1kB
Posted By: admin Views: 608
Date Added: Tue, Jun 17 2008

Here's a simple example of how to export ModelRight Model info to Excel.  Add a user-defined script object and copy/paste the following into it.  Then run it:

 

Sub Evaluate_OnLoad()
 Set Context = CreateObject("SCF.ScriptContext")
 Set ThisScript = Context.Object
 Set Options = Context.Options
 Set Model = ThisScript.Model

 Dim NumRows, x1, col
 NumRows = 2
 Set ExcelDoc = CreateObject("Excel.Application")
 ExcelDoc.Visible = true
 ExcelDoc.Workbooks.Add
 ExcelDoc.Range("A1").Value = "Table"
 ExcelDoc.Range("B1").Value = "Column"
 ExcelDoc.Range("C1").Value = "Datatype"
 Set Tables = Model.AsObject.Children("Table")
 For Each Table In Tables
  TableName = Table.Property("Name").AsString
  Set Columns = Table.Children("Column")
  For Each Column in Columns
   ExcelDoc.Range("A" + Cstr(NumRows)).Value = TableName
   ExcelDoc.Range("B" + Cstr(NumRows)).Value = Column.Property("Name").AsString
   ExcelDoc.Range("C" + Cstr(NumRows)).Value = Column.Property("Datatype").AsString   
   NumRows = NumRows + 1
  Next
 Next

 ExcelDoc.Columns("A:C").EntireColumn.AutoFit                   
 ExcelDoc.Rows("1:" + cstr(NumRows)).EntireRow.AutoFit
   

End Sub

Comments
 

John L said:

Very nice. Works great for me and easy to modify to export additional info as needed.
Mon, Jun 01 2009 7:13 PM
 

Doug F. said:

This is great! Question: How would I import data from Excel into Model Right?
Fri, Jun 05 2009 12:48 PM

Add Comment

Name (required)
Web Site (optional)
Comment (required)
Add