怎样判断当前是否有excel文件打开?

muniu 2003-08-19 11:15:27
同上。
...全文
54 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
felix 2003-08-19
  • 打赏
  • 举报
回复
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
hxy2003 2003-08-19
  • 打赏
  • 举报
回复
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

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧