I have an Excel 2007 VBA project which works fine on my computer and some others, but on some it hits error 32809 on a line that references the ActiveSheet object. I found that on the affected computers, the ActiveSheet object is not recognized. The ActiveWorkbook object works fine.
On the affected computers, if I create a new workbook, reference ActiveSheet, and activate the affected workbook, the ActiveSheet object works normally; I can get the Name property of ActiveSheet.
On my computer the VBA compiles fine. But on the affected computers, Compile stops on an "Option Explicit" line and returns the error:
"Contains references to object definitions that could not be found." But the selected entries in the References dialog look normal.
On the affected computers we've checked for updates but they were up to date; I assume IT handles updates remotely.
My thoughts are that:
Any ideas?
UPDATE:
Sample code, as requested:
Sub main()
Debug.Print ActiveSheet.Name
End Sub
UPDATE #2:
Thinking it might be workbook corruption, I rebuilt the workbook from scratch. But the new workbook had the same problem.
On a computer where the error was happening, I saved a copy of the file as xlsx, no macros. Then I closed and opened that file to ensure that the macros were gone. Then I copied back all VBA from the original file. Then I resaved as xlsm, with macros.
That file worked fine on the affected computer, and also worked fine on the original computer.
However, on the original computer, if I saved the file, then copied that to the affected computer, it was back to the original problem.
So that gives me a clumsy workaround anyway. Next I'll try KB article 3025036, "Cannot insert object" error after installing MS14-082 security update. Not the same error message but worth a try.
This problem went away only after removing all listbox controls. The listbox controls had been there a long time and had been working fine on the affected machines; I'm not sure what suddenly changed to make them not work on some computers.
As a workaround, I'm going to try deleting/creating the listboxes in runtime, instead of using the same listbox control. That way it's always a new listbox created on that computer.
UPDATE:
It turned out that the problem was a bad Office update -- update KB2596927 from the MS14-082 security update. We hadn't had a problem back in November when that update came out, but recently our corporate IT had tried removing KB2596927 from all computers. However, the removal was not successful on some. KB2596927 was still there on mine and some others, but gone from some.
I found that if, on a computer where the problem occurred, I removed the VBA and added it back, it worked on that comptuter and all our computers. But as soon as I modified the VBA on my computer and saved it, and distributed the workbook, the problem was back.
So I removed the KB2596927 Office update, and that fixed the problem. Now I can modify the VBA in the workbook on my computer, and distribute the workbook, and it works normally for everyone.