Hi Magnus
It's not recommended to use try-catch for something that's not a true exception (error). While this worked OK in the old Visual Basic world, in the .NET world this will slow your application considerably. Plus, the way you've set this up, creating the toolbar will execute even if some other error occurs.
Are you certain that the line of code in the "try" block actually causes an error to occur? Might it not leave the toolbarButton variable = null? (no time to test it for you...)
It would probably be better to use the FindControl method of the CommandBars collection. Make sure you've assigned your control a unique TAG value, and check for the control using this (instead of ID, which is only for built-in controls).
-- Cindy Meister (Word MVP) |