这是一个偷偷摸摸的解决方案,但它对我有用。
我对 Autoexec 宏执行 DoCmd.DatabaseTransfer acImport。
然后我使用 DoCmd.DatabaseTransfer acExport
将 autoexec 替换为空白
诀窍在于导出将覆盖
DoCmd.TransferDatabase acImport,
"Microsoft Access", sSourcePath,
acMacro, "autoexec", "autoexecSource"
DoCmd.TransferDatabase acExport,
"Microsoft Access", sSourcePath,
acMacro, "autoexecblank", "autoexec"
我为第二个 MDB 再次这样做
DoCmd.TransferDatabase acImport,
"Microsoft Access", sDestPath,
acMacro, "autoexec", "autoexecDest"
DoCmd.TransferDatabase acExport,
"Microsoft Access", sDestPath,
acMacro, "autoexecblank", "autoexec"
然后我可以进行所有比较以查找两个 MDB 之间的差异,而无需触发 autoexec 宏,因为我导入并替换了它们
然后我比较我导入的两个宏,然后将它们导出回数据库。
DoCmd.TransferDatabase acExport,
"Microsoft Access", sSourcePath,
acMacro, "autoexecSource", "autoexec"
DoCmd.TransferDatabase acExport,
"Microsoft Access", sDestPath,
acMacro, "autoexecDest", "autoexec"
显然,这个解决方案只能在 Access 中使用 VBA,但它确实有效。
希望这对某人有所帮助。