运行以下代码时,出现“对象变量或块变量未设置”错误消息。它在Access中并引用一个Excel电子表格。代码有什么问题?vba错误:对象变量或未设置块变量
wsTest.Range("A11").Activate
Do Until IsEmpty(ActiveCell)
intX = intX + wsTest.Cells(ActiveCell.Row, "L") 'error occurs on this line
intY = intY + wsTest.Cells(ActiveCell.Row, "I")
ActiveCell.Offset(1, 0).Select ' Step down 1 row to the next cell.
Loop
代码运行第一次,没有错误,只有第二次。关闭并重新打开Access“修复”问题。这与代码有什么关系?
错误发生在哪条线上? – mwolfe02 2011-04-12 19:45:41
我使用该信息更新了上面的代码。 – LFurness 2011-04-12 19:55:59
ActiveCell是指Excel对象,因此您可能应该使用XL应用程序参考来限定它。例如:xlApp.Activecell – 2011-04-13 00:21:56