以下是引用gvntw在2008-9-6 16:09:00的发言:死循环是因为没插入U盘,你可以修改一下,提示用户插入U盘,如: msg=Msgbox("系统检测无U盘,单击是,插入U盘重试,单击否,退出程序",vbyesno,"提示") if msg=vbyes then goto 1 else thisworkbook.close false end if 这样修改后正常.(已测试通过) Private Sub Workbook_Open() On Error Resume Next Set fs = CreateObject("Scripting.FileSystemObject") DrivesCount = fs.drives.Count Set d = fs.GetDrive(Chr(65 + DrivesCount)) sn = d.serialnumber If sn = -1330828335 Then 'U盘序列号 Exit Sub Else MsgBox "找不到密钥盘,系统将退出。" ThisWorkbook.Close False End If End Sub
下面的附件已加密:
tM3qMtuV.rar
(6.33 KB, 下载次数: 1084)
[此贴子已经被作者于2008-9-6 19:56:59编辑过] |