December 4, 2006

Depth charge

So I found a fun bug in Microsoft Excel XP. (It probably affects other versions, but I use XP on a daily basis.) While Wolf Rentzsch may be conflicted about talking about such a thing, I'm cool because:

  1. I'm not a contractor;
  2. I didn't try to find a workaround*.
So here we go.

Open up Microsoft Excel and create a new workbook, if it didn't do that for you automatically. Open up the VBA editor. (An easy shortcut is Alt-F11.) Open up the ThisWorkbook code module and enter the following code:

Option Explicit

Public Sub Workbook_Open()

Dim depth_charge As String
Dim i As Integer

For i = 1 To 88
depth_charge = depth_charge & i & ","
Next i
depth_charge = depth_charge & "89"

ThisWorkbook.Worksheets(1).Range("A1").Validation.Add _
Type:=xlValidateList, AlertStyle:=xlValidAlertStop, _
Operator:=xlEqual, Formula1:=depth_charge

End Sub

Close the VBA editor and save your workbook. Now close Microsoft Excel and open the workbook you just saved. (It goes without saying that you need to enable macros, which might mean that you need to set your macro security to Medium.) After the workbook opens, you should get an error. Click End at the error window.

Now have fun trying to terminate the Microsoft Excel process.

* (You may be wondering, why not just use the Win32 API to create ComboBoxes programmatically, instead of creating a half-assed combo box using Excel's data validation feature? To which I say, kill me now.)

Posted by Jeffrey at December 4, 2006 10:26 PM
What is a TrackBack? Learn more here.

TrackBack URL for this entry:
http://www.geekable.com/cgi-bin/mt-tb.cgi/1299

Listed below are links to the 0 weblogs that reference 'Depth charge' from Geekable.com.