Private Sub DetectExcel()
'该过程检测并登记正在运行的 Excel。
Const WM_USER = 1024
Dim hWnd As Long
'如果 Excel 在运行,则该 API 调用将返回其句柄。
hWnd = FindWindow("XLMAIN", 0)
If hWnd = 0 Then '0 表示没有 Excel 在运行。
Exit Sub
Else
'Excel 在运行,因此可以使用 SendMessage API
'函数将其放入运行对象表。
SendMessage hWnd, WM_USER + 18, 0, 0
End If
End Sub
这个是VB写的程序