19 April, 2010

Excel Solutions - Gross, but Occasionally Useful

So, once again maybe I'm behind the curve a bit, but I just found the Excel project types in VS2008. So in those cases where I need to hack something in Excel, I can now do it with managed code instead of VBA.

There were, however, a few things to note.
1) Security. The code needs to be Fully Trusted to run. In Admin Tools-> Microsoft .NET Framework 2.0 Configuration, go to Configure Code Access Security Policy. Go to Runtime Security Policy->User->Code Groups->All_Code, and add a new code group. I named mine "Ross Dev", based it on URL (specified my dev folder), and gave it Full Trust. Office projects are automatically given Full Trust, but at some point I had to do this, not sure why-- maybe when I tried to move it out of the original location.

This can also be done with the Caspol.exe commandline tool, but I like the GUI.

b) My app had to make a call to a web service, and it took a while to return data. I got a message about "blah blah blah pumping Windows messages blah blah" and mentioned an MDA ("Managed Debugging Assistant"). To turn this @#$% off, note the name of the MDA, go to the Debug->Exceptions... in VS, and expand "Managed Debugging Assistants"-- untick the trouble maker.

3c) The issue I haven't resolved, and therefore have just accepted, is that even though I created the project as an "Excel 2003" app (because the customer has not upgraded to Excel 2007 yet), when I close VS and re-open, it automatically updates the project to Excel 2007. No questions, prompts, or options-- it just does it. I don't know what will happen if it's put on machine with only Excel 2003 though. And I don't particularly care.

No comments:

Post a Comment