效果:
源码:
Sub 判断文件是否存在() Dim strcfg As String strcfg = "D:a.cfg" If Dir(strcfg, vbDirectory) = "" Then MsgBox "错误:配置文件不存在!" & Chr(10) & strcfg 'Chr(10)换行符 Exit Sub End If End Sub