[Inventor]
Inventor vba中判断excel是否打开
- Public appWorld As Excel.Application
- Public wbWorld As Excel.Workbook'
- ' Public shtWorld As Excel.Worksheet
- Sub Setup()
- On Error Resume Next '忽略错误
- Set appWorld = GetObject(, "Excel.Application") '查找一个正在运行的 Excel 拷贝
- If Err.Number <> 0 Then '如果 Excel 没有运行则
- Set appWorld = CreateObject("Excel.Application") '运行它
- End If
- Err.Clear ' 清除发生错误的 Err 对象
- On Error GoTo 0 '保留普通错误进程
- Set wbWorld = appWorld.Workbooks.Open(App.Path & "world.xls")
- End Sub
复制代码
|
|
|
|
|