获取mdb文件(MSACCESS)所有的源代码使用C#/ VBScript中 [英] Get all source code in mdb file (msaccess) using C#/VBScript

查看:549
本文介绍了获取mdb文件(MSACCESS)所有的源代码使用C#/ VBScript中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从一个访问数据库(窗体,模块) 。不使用Office互操作性展示

I would like to get all the source code from an Access database (forms, modules) without using Office interops.

我喜欢的 AllCodeToDesktop()函数的此处找到。但是从 MDB 文件中运行。

I liked the AllCodeToDesktop() function found here. However that runs from inside the mdb file.

将VBScript文件是什么加载MDB文件并运行它的功能?

What would a VBScript file be that loads the mdb file and runs that function on it?

推荐答案

要保存很多时候,是没有任何理由,为什么你不使用内置的文档管理?

To save a lot of time, is there any reason why you don’t use the built in documenter?

工具 - > analyze->文档管理器

Tools->analyze->documenter

以上具有产生具有在窗体,报表,模块和类模块的所有代码的报表的能力。此报告可以发送到字,甚至保存为文本文件。

The above has the ability to produce a report that has all code in forms, reports, modules and class modules. This report can be send to word or even saved as a text file.

我只提到这一点,以节省您的时间和精力。有没有必要在这里写任何代码

I only mentioning this to save you time and effort. There not a need to write any code here.

更​​多音符:
我不认为你可以做到这一点外。您可以使用MS-Access作为COM对象,并使用代码来拉出的代码作为文本,但你需要安装在计算机上访问。

more notes: I don’t think you can do this external. You can use ms-access as com object, and use code to pull out the code as text, but you need access installed on that computer.

有两种方法,一种是使用了saveastext命令。这将任何窗体,报表,代码等导出为文本文件(这是什么的源代码的加载项全部使用)。

There is two approaches, one is to use the saveastext command. This will export any form, report, code etc as a text file (this what the source code add-ins all use).

第二方法是编写自动化代码。以下是本机访问(VBA)代码,但你一样好支持COM对象的语言编写代码。该代码如下:

The 2nd approach is to write automation code. Here is code in native access (VBA), but you just as well write this code in any language that supports com objects. The code will look like:

  Dim db               As Database
  Dim Doc              As Document
  Dim mdl              As Module
  Dim lngCount         As Long
  Dim strForm          As String
  Dim strOneLine       As String
  Dim sPtr             As Integer

  Set db = CurrentDb()
  ' count module LOC

  For Each Doc In db.Containers("Modules").Documents
      DoCmd.OpenModule Doc.Name

      Set mdl = Modules(Doc.Name)

      lngCount = lngCount + mdl.CountOfLines
      For i = 1 To lngCount
         strOneLine = mdl.Lines(i, 1)
         Debug.Print strOneLine
      Next i

      Set mdl = Nothing
      DoCmd.Close acModule, Doc.Name

  Next Doc

上面的代码可以easliy体改到SEACH,或导出的文本。我认为使用saveastext较少的代码然而,但你得到的形式定义等,这可能不是你想要的。

The above code can be easliy modifed to seach, or export the text. I think using saveastext is less code however, but then you get the forms definition etc, and that likely not what you want.

这篇关于获取mdb文件(MSACCESS)所有的源代码使用C#/ VBScript中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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