Testing in the shapesheet for a user defined field or macro

Started by connifer, March 05, 2012, 05:03:33 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

connifer

O.k., I am not quite sure how to handle this issue or even where I should post it so I will start here but feel free to tell me if I need to be in an different forum . . .

I built a title block that is saved as a master shape intended to be dropped on a page.  There are 2 yellow squares that when double clicked call macros which open a form to edit the page properties or pop up the page select dialog.  The problem is in the stencil the macros don't exist and wouldn't make sense so if you double click it just barfs with a nonsensicle error.  What I would like is a simple shape sheet function or test that would allow me to look for the macro or a field in the doc or page which I can use to disable the double click macro if it doesn't have anything to call.  That would prevent errors which confuse users (and me sometimes when I am not thinking :-) if the shape is in the stencil or made its way to a doc that doesn't have the correct fields/macros.

. . . See the attached screenshot . . .



As an example:
Right now EventDblClick = RUNMACRO("UserFormCode.PageUserForm")

Instead create a statement in a new field which says something like:
User.ActivateMyMacro=SETF(GetRef(EventDblClick),IF(TheDoc!User.ActivateMacros=TRUE,"=RUNMACRO("UserFormCode.PageUserForm")",""))

No, this doesn't work.  I thought I had something close last friday but the whole formula would disappear if the field to be tested disappeared.  i.e.  I would delete the user defined field ActivateMacros from the doc properties and the formula above would disappear. I am hoping to make is so when people double click on the yellow square it doesn't throw an error if the macro it references doesn't exist.

Any ideas would be greatly appreciated!  I am kinda stuck and not even sure how to start.

Thanks
Bill
     

Jumpy

Interesting problem. This trick could work:

Place a VBA macro with the stencil and let that macro be called on dropevent (use Callthis, not Runmacro).
That VBA macro could check for certain User.Cells and if they exists can change the formula of the DblClickCell of your titleblock shape and fill it with your ="RunMacro...".

Be aware that the macro in the stencil can't check for other macros that are not on the stencil, especially it doensn't know and can't test if the UserForm exists and the VBA-Code on the UserForm. Therefor you have to use a workarround with a User.Cell somewhere as a flag to show if that document contains the UserForm and the code.