访问MS Access应用程序中的原始代码 [英] Accessing the raw code in an MS Access application

查看:118
本文介绍了访问MS Access应用程序中的原始代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试找到一些关于访问MS Access中的原始代码的信息(我使用v2007,但应该适用于所有版本)。



例如,我想列出应用程序中每个代码隐藏表单和模块中的所有函数,并列出它们的参数。



你将如何实现? / p>

注意:我当然假设应用程序没有编译。

解决方案

您可以将所有代码输出到文本,并通过另一个程序运行它或将其加载到数据库中,或者您可以编写代码以使用VBE访问代码。

  Sub AllCodeToDesktop()
'FileSystemObject对象的引用是Windows脚本宿主对象模型
',但不必为此过程添加引用。

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)

'设置文件。
设置f = fs.CreateTextFile(SpFolder(Desktop)&\_
& Replace(CurrentProject.Name,。,)&.txt)

'对于项目中的每个组件...
对于每个mdl在VBE.ActiveVBProject.VBComponents
'使用行数...
i = VBE.ActiveVBProject .VBComponents(mdl.Name).CodeModule.CountOfLines
'将代码放在字符串中...
如果VBE.ActiveVBProject.VBComponents(mdl.Name).codemodule.CountOfLines> 0 Then
strMod = VBE.ActiveVBProject.VBComponents(mdl.Name).codemodule.Lines(1,i)
End如果
',然后将其写入文件,与
'一些等号和组件名称。
f.writeline String(15,=)& vbCrLf& mdl.Name _
& vbCrLf& String(15,=)& vbCrLf& strMod
下一页

关闭eveything
f.Close
设置fs =无
结束Sub

发件人: http:/ /wiki.lessthandot.com/index.php/Code_and_Code_Windows


I've been trying to find some information about getting access to the raw code in MS Access (I use v2007 but should probably apply to all versions).

Say for instance that I'd like to list all functions in every code-behind form and module in the application and list their parameters.

How would you achieve this?

Note: I'm of course assuming that the application is not compiled.

解决方案

You can output all the code to text and run it though another program or load it into a database, or you can write code to access the code using VBE.

   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

这篇关于访问MS Access应用程序中的原始代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆