Click here to Skip to main content
15,878,945 members
Articles / Programming Languages / VBScript
Tip/Trick

Generating Data Dictionary or Database Design Document using MS Word Macros

Rate me:
Please Sign up or sign in to vote.
3.58/5 (10 votes)
31 Mar 2008CPOL2 min read 73.7K   1.6K   17   14
Generating Data Dictionary or Database Design Document using MS Word macros.

Introduction

Manually preparing a data dictionary document will take ages in MS Word which contains 100's of tables, stored procedures, functions, triggers, views, indexes, etc. in a SQL Server database as you need to type each and every column of the table along with the associated dependencies. I need a data dictionary document which generates the database schema automatically in one click with nice formatting. For this I did a lot of research in Google to find the solution and finally I wrote my own code to do this functionality and I thought to share my experience with you all.

The main purpose of this article is to generate the data dictionary document automatically by simply running the macro code in MS Word within seconds.

I am not a VBA guru but I still started doing some kind of researching on VBA code in Google and I got ideas from different forums, many thanks to those people who posted their ideas.

I hope this solution will help you to prepare a data dictionary document. Here we start...

Basically, this code will prepare for you the following information in the document. The table name with the following dependent information:

  • Table Column Details
  • Indexes
  • Views
  • Stored Procedures
  • Functions
  • Triggers
  • Primary Keys
  • Foreign Keys
  • Default Constraints
  • Identity Columns

Using the code

Following are the steps to run this code:

  1. Simply open a blank Word document (it is mandatory).
  2. Go to menu Tools->Macro->Macros->Create, this will create a new Visual Basic module editor.
  3. Paste this code.
  4. Change the connection string as per your SQL Server credentials (it is mandatory).
  5. Add references to Microsoft ActiveX Data Objects Library from the menu Tools->References.
  6. Run the macro by pressing F5 from the VBA editor.

data_dictionary/document_template.jpg

Points of Interest

This code will generate the data dictionary document automatically with one click and it is simple to use this code.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
United Kingdom United Kingdom
Completed Masters in Computer Applications.

Comments and Discussions

 
Questionit works but it did not get stored procedures Pin
Member 1198044513-Sep-15 5:34
Member 1198044513-Sep-15 5:34 
QuestionI modified a Pk problem, i ran this in SQL Server 2014 and Works ok. Pin
Pavel Flores29-Jul-15 14:53
Pavel Flores29-Jul-15 14:53 
QuestionEdit macro for Description it's not coming in Origiranl Pin
Member 111947325-Nov-14 2:14
Member 111947325-Nov-14 2:14 
QuestionNeed this for a oracle database Pin
Member 1048363723-Dec-13 3:02
Member 1048363723-Dec-13 3:02 
Questionvery nice tool Pin
harsh.programmer22-Feb-12 0:35
harsh.programmer22-Feb-12 0:35 
Questionfor non VB developers Pin
Member 852727129-Dec-11 19:07
Member 852727129-Dec-11 19:07 
GeneralThanks Pin
sreelekhamenon8-Dec-10 14:07
sreelekhamenon8-Dec-10 14:07 
Generalthanks Pin
velpetit9-Dec-09 18:06
velpetit9-Dec-09 18:06 
Generalole db Pin
Svetlana Tipping18-Feb-09 22:38
Svetlana Tipping18-Feb-09 22:38 
GeneralWord 2007 Pin
Hawks Talon17-Jun-08 8:09
Hawks Talon17-Jun-08 8:09 
GeneralMacro not working Pin
Niranjan Singh14-Apr-08 3:15
Niranjan Singh14-Apr-08 3:15 
GeneralRe: Macro not working Pin
grom_boy14-Apr-08 23:36
grom_boy14-Apr-08 23:36 
GeneralRe: Macro not working [modified] Pin
AndrewGail24-Apr-08 5:12
AndrewGail24-Apr-08 5:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.