views:

590

answers:

3

(DISCLAIMER: I'm not a programmer, I spend my time on serverfault, I'm just a lowly admin)

We have an excel spreadsheet with vb code in it that was created in Office 2003.

We've recently gone to Office 2007, and the spreadsheet continued to work as normal.

However, after installing service pack 2 for Office 2007 the spreadsheet now fails with an error stating : "variable not defined"

If I comment out the "Option Explicit" statement at the top of the code then the code works fine.

What I don't understand is that when the error occurs it is occurring on something that isn't even a variable (unless I'm wrong?).

Click the below image to see the screenshot:

*http://filedb.experts-exchange.com/incoming/2009/06_w23/t144890/snip.JPG*

A: 

The variable is an object that exists in the excel spreadsheet itself, hence the events you see above state DataGrid1_Click which is an event handler. This is why you can't see the variable definition. Perhaps DataGrids aren't supported in post-SP2 installs?

Kezzer
+2  A: 

The reference to the package/addin/whatever that DataGrid exists in probably needs to be rereferenced. Check Tools -> References in the Menu.

EDIT: OK, here's what I found, it appears that if you install Microsoft Security Advisory 960715, that that control is killed. There's fixes which may or may not work for you. A good article is on this blog:

VSOD Blog

Lance Roberts
I attempted this by unchecking the "Microsoft DataGrid Control 6.0" (MSDATGRD.OCX file) in the References. Saving the .xlsm, Then adding it back in.Still get the same error.
TheCleaner
A: 
  1. Verify that the object is still named "datagrid1".
  2. Try prefixing the object with "Me" (Me.DataGrid1)
  3. Could be an early symptom of corruption. Try cutting (ctrl-x) the entire code. Then from the debug menu click compile. Paste the code back in an compile again. Sometimes this simple measure will fix it. (If not an you still suspect corruption there are more advanced measure to be taken.)
Oorang