错误恢复下一步停止工作 [英] On error resume next stopped working

查看:100
本文介绍了错误恢复下一步停止工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我目前的角色中,我继承了(我以前一生都是邪恶的)一些MS Access VBA已经工作多年了。



今天它随机开始抛出错误。我将其跟踪到一段代码,该代码使用了旧的on-error-resume-next技巧,VB6和VBA程序员必须在没有良好错误处理的情况下使用它。



我可以重新创建问题的最小代码是...

In my current role I inherited (I must have been evil in a previous life) some MS Access VBA which has been working for years.

Today it randomly started throwing errors. I tracked it down to a piece of code that uses the old on-error-resume-next trick that VB6 and VBA programmers had to use in the absence of decent error handling.

The minimum code that I can recreate the problem with is...

On Error Resume Next
ws.Range("A1:K18").Replace "", "0"
On Error GoTo 0

其中 ws 是Excel工作簿中的工作表(已在Access VBA中添加),范围内填充数据(没有空单元格)(如果有空单元格那么Repl ace没有抛出我找不到任何要替换的东西的消息,我正试图避免)



我已经尝试了所有常用的东西(见下文)无济于事。有趣的是,MS Excel似乎没有受到影响。



解决这个特定问题的方法显然是首先查找并且只在必要时发出Replace命令。但是,我意识到业务中有数百种EUP解决方案,如果可能的话我想找到一个通用的解决方案。



这是Windows 10, Office 365 ProPlus与Access版本1803(Build 9126.2351),即VBA Retail 7.1,自上次工作以来没有应用Office更新。



我尝试过什么:



- 检查IDE,工具,选项,常规,错误陷阱尚未更改为中断所有错误

- 尝试了该设置的所有组合

- 压缩和修复数据库

- 完全反编译有问题的数据库并重新编译

- 应用了一个gpupdate / force和硬重启

Where ws is a worksheet in an Excel workbook (that was added in the Access VBA) and the range is filled with data (no empty cells) (As, if there are empty cells then Replace does not throw up the "I can't find anything to replace" message that I'm trying to avoid)

I've tried all the usual stuff (see below) to no avail. Interesting, MS Excel does not seem to be affected.

The way around this specific problem is obviously to do a Find first and only issue the Replace command if it is necessary. However, I'm conscious that there are hundreds of EUP solutions out in the business and I would like to find a generic fix if possible.

This is Windows 10, Office 365 ProPlus with Access Version 1803 (Build 9126.2351) i.e. VBA Retail 7.1, No Office updates have been applied since it last worked.

What I have tried:

- Checking the IDE,Tools, Options, General, Error Trapping hadn't been changed to "Break on All Errors"
- Tried all combinations of that setting
- Compact and Repaired the database
- Fully decompiled the database in question and recompiled
- applied a gpupdate /force and hard reboot

推荐答案

正如我们在对这个问题的评论中同意Caroline一样,我想分享一下我解决这个问题的方法问题......



方法#1 - 如果是在一个或多个模块中找到了未识别的标志/字符:



  • 导出并删除所有模块(UserForms也是如此)
  • 然后压缩并修复数据库
  • 检查文件并使用记事本进行编辑 - 如有必要
  • 导入模块并再次压缩和修复数据库
As we agreed with Caroline in the comments to the question, i would like to share my ways i've resolved such of issues...

Method #1 - in case when unidentified signs/characters have been found in one or more modules:

  • export and remove all modules (UserForms too)
  • then compact and repair database
  • inspect files and edit with notepad - if necessary
  • import modules and compact and repair database again


  • 创建新数据库
  • 导入表格和查询,然后导入模块(甚至是UserForms),但不是全部

        注意:一个一个地导入以检测哪一个被破坏...每次导入后,编译代码,压缩和修复数据库
  • 检查文件系统和文件系统元数据 - 使用 chkdsk C:/ f / x 命令 [ ^ ]
  • 修复文件系统完整性 - 使用 sfc / scannnow 命令 [ ^ ]
  • 清理系统并删除不必要的还原点,请参阅:

    • check file system and file system metadata - using chkdsk C: /f /x command[^]
    • repair file system integrity - using sfc /scannnow command[^]
    • clean system and remove unnecesarry restore points, see:

      • Script to delete System Restore Points[^]
      • Managing Restore Points with PowerShell -- Microsoft Certified Professional Magazine Online[^]
      • How To Delete Restore Points In Windows 10[^]
      • 修复或重新安装MS Office


      这篇关于错误恢复下一步停止工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆