设为首页 - 加入收藏 ASP站长网(Aspzz.Cn)- 科技、建站、经验、云计算、5G、大数据,站长网!
热搜: 创业者 手机 数据
当前位置: 首页 > 服务器 > 系统 > 正文

ms-access – 从Microsoft Access导出代码

发布时间:2021-01-25 06:32 所属栏目:52 来源:网络整理
导读:有没有办法将Microsoft Access代码批量导出到文件?我看到我可以一次导出一个文件,但有数百个,我会一整天都在这里.在任何地方都没有“全部导出”或多选导出? 解决方法 要将所有代码输出到桌面,包括表单和报表中的代码,您可以将其粘贴到标准模块中,然后按F5

有没有办法将Microsoft Access代码批量导出到文件?我看到我可以一次导出一个文件,但有数百个,我会一整天都在这里.在任何地方都没有“全部导出”或多选导出?

解决方法

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

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提供的列表.

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

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

(编辑:ASP站长网)

    网友评论
    推荐文章
      热点阅读