Solved

Wrong macro is activated when text is hidden

Posted on 2014-04-27
3
277 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
[X]
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
3 Comments
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 500 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…

738 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