Solved

Wrong macro is activated when text is hidden

Posted on 2014-04-27
3
278 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

Independent Software Vendors: 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

This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
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…
Suggested Courses
Course of the Month9 days, 14 hours left to enroll

623 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