这个程序在我的电脑上需要1-2秒。
慢度发生在行Debug.Print Err.Description上
如果我用Err.number替换它,它需要0。
如果我更改代码以显示Type Mismatch错误消息,问题就会出现。
我正在使用Excel 2007,64位Windows。
我已经禁用了所有的外接程序
我将以下代码放入一个全新的.xlsm文件中。
问题不在于debug.print,如果我将其转换为字符串比较,问题就会继续存在。
Private Declare Function GetTickCount Lib "kernel32" () As Long
Public Sub Testing()
Err.Clear
Application.DisplayAlerts = False
Application.CutCopyMode = False
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.EnableEvents = False
On Error GoTo Problem
Dim a As Double
a = 10 / 0
Problem:
Dim sOutput As String
Dim lStart As Long, lEnd As Long
lStart = GetTickCount
Debug.Print Err.Description
lEnd = GetTickCount
gsOutput = "Time requires : " & (lEnd - lStart) / 1000 & "s"
Debug.Print gsOutput
End Sub任何帮助都会很好。
编辑问题及解决方案:http://support.microsoft.com/kb/2683270
顺便说一句,如果微软已经提出了这个问题,我认为这不是一个本地化的问题。
发布于 2013-03-01 10:02:44
基本上,问题在于本地计算机上缺少一些注册表值。
如建议的那样这里
缺少由Excel进程在错误处理期间使用的winhelp.ini (您可以使用建议的工具进行检查)。
因此,它正在从其他%PATH%变量中查找到网络驱动器的C:\Windows\winhelp.ini。
1-2秒是网络延迟.
通过添加提到的注册表解决了这个问题。
HTH
https://stackoverflow.com/questions/15062935
复制相似问题