Check for visibility of Palette

I had a similar issue when adding macros to a palette. Peter solved it in the following post: