پیدا کردم
در work book open
کد HTML:
If IsProcessRunning("1.EXE") = True Then
MsgBox "برنامه قبلا باز شده است", vbCritical + vbMsgBoxRight, "خطا"
ActiveWorkbook.Close savechanges:=False
Else
End If
و این مازول هم اضافه بشه به فایل
کد:
Public Const SW_RESTORE = 9
Public Declare Function BringWindowToTop Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Any, ByVal lpWindowName As Any) As Long
Public Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Function IsProcessRunning(process As String)
Dim objList As Object
Set objList = GetObject("winmgmts:") _
.ExecQuery("select * from win32_process where name='" & process & "'")
If objList.Count > 0 Then
IsProcessRunning = True
Else
IsProcessRunning = False
End If
End Function
علاقه مندی ها (Bookmarks)