Private Sub Workbook_Open() mypath = "d:\" myfile = Dir(mypath & "test.TXT") Execute If Execute < 1 Then MsgBox "請在指定電腦作業,才能開啟檔案", vbOKOnly ActiveWorkbook.Close SaveChanges:=False End If End Sub