Dim appWorld As Excel.Application
Err.Clear
On Error Resume Next
Set appWorld = GetObject(, "Excel.Application") '查找一个正在运行的 Excel 拷贝
If Err.Number <> 0 Then 'Excel 没有运行
Set appWorld = CreateObject("Excel.Application") '运行它
Else
appWorld.Visible = True
End If
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As Any) As Long
Private Sub Command1_Click()
Dim hWnd_xl As Long
hWnd_xl = FindWindow("XLMain", 0&)
MsgBox hWnd_xl
End Sub