excel - 如何检查工作簿是否存在?
问题描述
我有一个变量(WB)。我将活动工作簿分配给该变量。
我想检查 WB 是否设置为 activeworkbook 或者它是否仍然为空。如果它存在,我将关闭工作簿。
解决方案
您可以检查对象变量是否由条件设置
if wb is nothing then .... ' not set
if not wb is nothing then .... ' is set
你的情况
if not wb is nothing then
if wb.name = thisworkbook.name then wb.close
end if
或在一行中
if not wb is nothing then if wb.name = thisworkbook.name then wb.close
推荐阅读
- numpy - drawcontours中的opencv错误 - 眼睛运动检测python代码
- python - 如何在for循环中将值放在迭代列表的后面?
- android - EditText 没有关注带有 NestedScrollView 的 CoordinatorLayout
- javascript - 创建两个共同依赖
- java - 嵌套表 docx4j
- wordpress - 离子不从 url wp-json 和 ionic4 加载图像
- r - 我经常收到关于 opt() 函数在哪个包中的错误?我该如何处理?
- git - 我将一个提交合并到 master 中,现在收到一条关于挑选樱桃的消息。不胜感激建议什么是安全的
- jquery - jQuery替换方法不会用新值更新旧值
- java - Java SQL Prepared Statement 问题与数组和 Where... IN 列表