去评论
距米网-精简版

Inventor vba中判断excel是否打开

JUMU
2020/01/21 16:25:59
  1. Public appWorld As Excel.Application
  2. Public wbWorld As Excel.Workbook'
  3. ' Public shtWorld As Excel.Worksheet

  4. Sub Setup()
  5. On Error Resume Next '忽略错误
  6. Set appWorld = GetObject(, "Excel.Application") '查找一个正在运行的 Excel 拷贝
  7. If Err.Number <> 0 Then '如果 Excel 没有运行则
  8. Set appWorld = CreateObject("Excel.Application") '运行它
  9. End If
  10. Err.Clear ' 清除发生错误的 Err 对象

  11. On Error GoTo 0 '保留普通错误进程

  12. Set wbWorld = appWorld.Workbooks.Open(App.Path & "world.xls")
  13. End Sub