防上程式重覆執行

原始來源: showje

Option Explicit
Public Sub CheckExist(fm As Form)
Dim title As String
If App.PrevInstance Then
   title = App.title
   Call MsgBox("這程式已執行", vbCritical)
   App.title = ""    '如此才不會Avtivate到自己
   fm.Caption = ""
   AppActivate title 'activate先前就已行的程式
   End
End If
End Sub

Private Sub Form_Load()
Call CheckExist(Me)
End Sub