|
我加入本论坛也有几年的时间了,发现这里真是卧虎藏龙,好多高手自编分析工具深入探索access的文档结构、扩展文档功能,揭开其中不为常人所知的奥秘........
而我这些年来只是透过Ms office帮助,编写些入门级的管理系统。真想把自己office方面的应用知识往上提高。
下面是我从国外某网站拷来的一段关于Application.SaveAsText的代码,可作为一个access文档的分析工具(高手tmtony早就详文说及,网上有相关转载)
在此借文抛砖引玉,还望高手们提供些分析access的工具或是未公开的方法的应用等内容。
'====================================================================
' Name: DocDatabase
' Purpose: Documents the database to a series of text files
'
' Author: Arvin Meyer
' Date: June 02, 1999
' Modified: Charles D Clayton Jr
' Date: April 14, 2004
' Comment: Uses the undocumented [Application.SaveAsText] syntax
' To reload use the syntax [Application.LoadFromText]
'====================================================================
On Error GoTo Err_DocDatabase
Dim dbs As Database
Dim cnt As Container
Dim doc As Document
Dim i As Integer
Dim F As String 'folder for forms
Dim Q As String 'folder for queries
Dim R As String 'folder for reports
Dim M As String 'folder for modules
Dim S As String 'folder for scripts
Dim T As String 'folder for tables
Dim strDayPrefix As String 'date
Dim strPath As String 'pathway
'Initial creation of folders
strDayPrefix = Format(Now, "mm-dd-yyyy--hh-nn-ss")
strPath = "C:\4P Backup\"
'Check for the folder
If Len(Trim(Dir(strPath, vbDirectory))) > 0 Then
'the file already exists
Else
MkDir (strPath) 'Main Folder for all backups
End If
MkDir (strPath & strDayPrefix) 'folder for today's backup
MkDir (strPath & strDayPrefix & "\forms\") 'can only create only subdirectory at a time
MkDir (strPath & strDayPrefix & "\Reports\")
MkDir (strPath & strDayPrefix & "\Scripts\")
MkDir (strPath & strDayPrefix & "\Modules\")
MkDir (strPath & strDayPrefix & "\Queries\")
MkDir (strPath & strDayPrefix & "\Tables\")
'Define variables
F = strPath & strDayPrefix & "\Forms\"
R = strPath & strDayPrefix & "\Reports\"
S = strPath & strDayPrefix & "\Scripts\"
M = strPath & strDayPrefix & "\Modules\"
Q = strPath & strDayPrefix & "\Queries\"
T = strPath & strDayPrefix & "\Tables\"
Set dbs = CurrentDb() ' use CurrentDb() to refresh Collections
'Extract information and save to text file
Set cnt = dbs.Containers("Forms")
For Each doc In cnt.Documents
Application.SaveAsText acForm, doc.Name, F & doc.Name & ".txt"
Next doc
Set cnt = dbs.Containers("Reports")
For Each doc In cnt.Documents
Application.SaveAsText acReport, doc.Name, R & doc.Name & ".txt"
Next doc
Set cnt = dbs.Containers("Scripts")
For Each doc In cnt.Documents
Application.SaveAsText acMacro, doc.Name, S & doc.Name & ".txt"
Next doc
Set cnt = dbs.Containers("Modules")
For Each doc In cnt.Documents
Application.SaveAsText acModule, doc.Name, M & doc.Name & ".txt"
Next doc
For i = 0 To dbs.QueryDefs.Count - 1
Application.SaveAsText acQuery, dbs.QueryDefs(i).Name, Q & dbs.QueryDefs(i).Name & ".txt"
Next i
Set cnt = dbs.Containers("Tables")
For Each doc In cnt.Documents
Application.SaveAsText acTable, doc.Name, T & doc.Name & ".txt"
Next doc
'Clear Memory
Set doc = Nothing
Set cnt = Nothing
Set dbs = Nothing
Exit_DocDatabase:
Exit Sub
Err_DocDatabase:
Resume Next
' Select Case Err
' Case Is = 2001
' Resume Next
' Case Else
' MsgBox Err.Number & " " & Err.Description
' Resume Next
'' Resume Exit_DocDatabase
' End Select |
|