Enable a user to double-click text in a document to change its value

Eg: change a Y to an N and then to a ? and then back to a Y

Article contributed by Bill Coan

Use a macrobutton field.  A macrobutton field is a placeholder that displays a value (such as Y, N, or ?) and can run a macro when you double-click it. The macro can do anything you want it to do, including change the displayed value.

1.

Before creating the macrobutton, Create the macro which you want to run when the field is double-clicked. The following macro will exactly fit the needs described above:

Sub SymbolCarousel()

Select Case Selection.Fields(1).Code.Characters(29)
  Case "Y"
    Selection.Fields(1).Code.Characters(29) = "N"
  Case "N"
    Selection.Fields(1).Code.Characters(29) = "?"
  Case "?"
    Selection.Fields(1).Code.Characters(29) = "Y"
  Case Else
End Select

End Sub

2.

After creating the SymbolCarousel macro, create the macro button by positioning the cursor where you want the N/Y/? value displayed. Then press Ctrl+F9 to insert a set of field braces { }. (Don't just type the braces. You must insert them using Ctlr+F9.)

3.

Within the braces, type very carefullly the exact character string shown between braces below (but don't type the braces). Be sure to leave a space before the word MACROBUTTON, before SymbolCarousel, and before N. Do NOT put a space after the N.

{ MACROBUTTON SymbolCarousel N }

4.

Right-click the field expression and choose Toggle Field codes.

5.

Double-click and see if the N changes to a ?. Double-click again and see if it changes to a Y. Again and it should change back to N.


Click to view Terms of Use page

Click to view Disclaimer page