从Microsoft Access导出代码 [英] exporting code from Microsoft Access

查看:386
本文介绍了从Microsoft Access导出代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将Microsoft Access代码批量导出到文件?我看到我一次可以导出一个文件,但是有数百个文件,而且我会整天待在这里.哪里没有全部导出"或多选导出功能?

Is there any way to bulk-export Microsoft Access code to files? I see I can export one file at a time, but there are hundreds and I'll be here all day. It there no "Export All" or multi-select export anywhere?

推荐答案

要将所有代码(包括表单和报表中的代码)输出到桌面,您可以将其粘贴到标准模块中,然后按F5或通过F8逐步运行.您可能希望先填写桌面文件夹的名称.

To output all code to desktop, including code from forms and reports, you can paste this into a standard module and run it by pressing F5 or step through with F8. You may wish to fill in the name of the desktop folder first.

   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.
   ''SpFolder is a small function, but it would be better to fill in a
   ''path name instead of SpFolder(Desktop), eg "c:\users\somename\desktop"
   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 i > 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

要获取特殊文件夹,可以使用Microsoft提供的列表.

To get special folders, you can use the list supplied by Microsoft.

枚举特殊文件夹: http://www.microsoft .com/technet/scriptcenter/guide/sas_fil_higv.mspx?mfr = true

来自: http://wiki.lessthandot.com/index.php/Code_and_Code_Windows

这篇关于从Microsoft Access导出代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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