我一直在尝试查找一些有关访问 MS Access 中的原始代码的信息(我使用 v2007,但可能应该适用于所有版本)。
举例来说,我想列出应用程序中每个代码隐藏表单和模块中的所有函数并列出它们的参数。
你将如何实现这一目标?
注意:我当然假设该应用程序未编译。
您可以将所有代码输出为文本并通过另一个程序运行它或将其加载到数据库中,或者您可以编写代码来使用 VBA 访问代码。
Sub AllCodeToDesktop()
'The reference for the FileSystemObject Object is Windows Script Host Object Model
'but it not necessary to add the reference for this procedure.
Dim fs As Object
Dim f As Object
Dim strMod As String
Dim mdl As Object
Dim i As Integer
Set fs = CreateObject("Scripting.FileSystemObject")
'Set up the file.
Set f = fs.CreateTextFile(SpFolder(Desktop) & "\" _
& Replace(CurrentProject.Name, ".", "") & ".txt")
'For each component in the project ...
For Each mdl In VBE.ActiveVBProject.VBComponents
'using the count of lines ...
i = VBE.ActiveVBProject.VBComponents(mdl.Name).CodeModule.CountOfLines
'put the code in a string ...
If VBE.ActiveVBProject.VBComponents(mdl.Name).codemodule.CountOfLines > 0 Then
strMod = VBE.ActiveVBProject.VBComponents(mdl.Name).codemodule.Lines(1, i)
End If
'and then write it to a file, first marking the start with
'some equal signs and the component name.
f.writeline String(15, "=") & vbCrLf & mdl.Name _
& vbCrLf & String(15, "=") & vbCrLf & strMod
Next
'Close eveything
f.Close
Set fs = Nothing
End Sub
From: http://wiki.lessthandot.com/index.php/Code_and_Code_Windows http://wiki.lessthandot.com/index.php/Code_and_Code_Windows
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)