ms-access – 从Microsoft Access导出代码
发布时间:2021-01-26 22:02:53 所属栏目:系统 来源:网络整理
导读:有没有办法将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:userssomenamedesktop" 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 (编辑:好传媒网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |