thenelson
asked on
Wrong macro is activated when text is hidden
I have the following text in a MS Word document:
I have fixed this problem by adding this code(ToBeAddressed is in a bookmark called RecommendToBeAddressed):
{MACROBUTTON ToBeAddressed To be considered at a future visit}
Medication changes:
Add stretches, exercises
Referal to:
Tobacco use:
{MACROBUTTON Medications Medications}:
When the text
{MACROBUTTON ToBeAddressed To be considered at a future visit}
Medication changes:
Add stretches, exercises
Referal to:
Tobacco use:
is hidden and I click on the field {MACROBUTTON Medications Medications} is clicked, the macro ToBeAddressed is activated instead of the macro Medications.I have fixed this problem by adding this code(ToBeAddressed is in a bookmark called RecommendToBeAddressed):
Sub ToBeAddressed()
If ActiveDocument.Bookmarks("RecommendToBeAddressed").Range.Font.Hidden = True Then
Medications
Exit Sub
End If
Which runs the Medications sub instead. But I am constantly running into this problem and I wonder if there is a better way to handle it?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Actually if you put an unhidden space at the end at any of the intermediate lines, it would still work, but be completely unseen (without the slight indent that would result from my first suggestion).
ASKER
I can't use an unhidden space at the end at any of the intermediate lines because all the lines between
{MACROBUTTON ToBeAddressed To be considered at a future visit}
and
{MACROBUTTON Medications Medications}:
are hidden.
But taking your idea, I placed a no width non break character (in special characters) in front of the
{MACROBUTTON Medications Medications}:
and that took care of it. The no width non break character does not show up unless show all characters is selected and it does not print.
{MACROBUTTON ToBeAddressed To be considered at a future visit}
and
{MACROBUTTON Medications Medications}:
are hidden.
But taking your idea, I placed a no width non break character (in special characters) in front of the
{MACROBUTTON Medications Medications}:
and that took care of it. The no width non break character does not show up unless show all characters is selected and it does not print.