UtterAccess HomeUtterAccess Wiki

Welcome Guest ( Log In | Register )

Custom Search
Edit Discussion
> Document Data Macros    

Contents

Document Data Macros

If you have tables with data macros and wish to document them, this code is for you user posted image

This code was written for the beta version.

In the Access 2010 release version, there is also the new SaveAsAXL / LoadFromAXL methods that are equivalent to SaveAsText / LoadFromText, but use XML for the formats of all objects.


CODE

document all table macros

Sub DocumentDataMacros()

'loop through all tables with data macros
'write data macros to external files
'open folder with files when done

' click HERE
' press F5 to Run!

' Crystal
' April 2010

On Error GoTo Proc_Err

' declare variables
Dim db As DAO.Database _
, r As DAO.Recordset

Dim sPath As String _
, sPathFile As String _
, s As String

' assign variables
Set db = CurrentDb

sPath = CurrentProject.Path & "\"

s = "SELECT [Name] FROM MSysObjects WHERE Not IsNull(LvExtra) and Type =1"

Set r = db.OpenRecordset(s, dbOpenSnapshot)

' loop through all records until the end
Do While Not r.EOF
sPathFile = sPath & r!Name & "_DataMacros.xml"
'Big thanks to Wayne Phillips for figuring out how to do this!
SaveAsText acTableDataMacro, r!Name, sPathFile
'have not tested SaveAsAXL -- please share information if you do
r.MoveNext
Loop

' give user a message
MsgBox "Done documenting data macros for " & r.RecordCount & " tables ", , "Done"

Application.FollowHyperlink CurrentProject.Path

Proc_Exit:
' close and release object variables
If Not r Is Nothing Then
r.Close
Set r = Nothing
End If

Set db = Nothing
Exit Sub

Proc_Err:
MsgBox Err.Description, , _
"ERROR " & Err.Number _
& " DocumentDataMacros"

Resume Proc_Exit
Resume

End Sub

document data macros for a specific table

Sub DocumentDataMacros_OneTable()

'write data macros for specified table to external file and open when done

' click HERE
' press F5 to Run!

' Crystal
' April 2010

Dim sPathFile As String _
, sTableName As String

' CUSTOMIZE to YOUR TABLENAME
sTableName = "MyTablename"

sPathFile = CurrentProject.Path & "\" & sTableName & "_DataMacros.xml"

'have not tested SaveAsAXL -- please share information if you do
SaveAsText acTableDataMacro, sTableName, sPathFile

MsgBox "Done documenting data macros for " & sTableName

Application.FollowHyperlink sPathFile
End Sub
Edit Discussion
Custom Search
Thank you for your support!
This page has been accessed 10,429 times.  This page was last modified 01:50, 25 January 2012 by Jack Leach. Contributions by strive4peace2010 and Glenn Lloyd  Disclaimers