Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Wrong macro is activated when text is hidden

Posted on 2014-04-27
3
Medium Priority
?
283 Views
Last Modified: 2014-04-27
I have the following text in a MS Word document:
{MACROBUTTON ToBeAddressed To be considered at a future visit}
	Medication changes:
	Add stretches, exercises
	Referal to: 
	Tobacco use: 
{MACROBUTTON Medications Medications}: 

Open in new window

When the text
{MACROBUTTON ToBeAddressed To be considered at a future visit}
	Medication changes:
	Add stretches, exercises
	Referal to: 
	Tobacco use: 

Open in new window

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

Open in new window

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?
0
Comment
Question by:thenelson
  • 2
3 Comments
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 2000 total points
ID: 40026024
Your workaround to this undocumented feature (i.e. bug) looks as good as any other.

One alternative would be to insert a non-hidden space in front of the second macrobutton field.
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 40026042
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).
0
 
LVL 39

Author Closing Comment

by:thenelson
ID: 40026314
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.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Cancel future meetings from user mailboxes in Office 365 using Remove-CalendarEvents
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question