public function autocompactcurrentproject() dim fs, f, s, filespec dim strprojectpath as string, strprojectname as string strprojectpath = application.currentproject.path strprojectname = application.currentproject.name filespec = strprojectpath & "/" & strprojectname set fs = createobject("scripting.filesystemobject") set f = fs.getfile(filespec) s = clng(f.size / 1000000) ‘转换文件大小为mb if s > 20 then ‘修改此处的20m为你自己需要的值 application.setoption ("auto compact"), 1 ‘压缩程序 else application.setoption ("auto compact"), 0 ‘不压缩程序 end if end function