Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Wrong macro is activated when text is hidden

Posted on 2014-04-27
Medium Priority
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
        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?
Question by:thenelson
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 76

Accepted Solution

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.
LVL 76

Expert Comment

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).
LVL 39

Author Closing Comment

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}
     {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.

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

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

This article describes a serious pitfall that can happen when deleting shapes using VBA.
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

722 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