Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / July 2005

Tip: Looking for answers? Try searching our database.

Hidden Text Using Checkbox

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dave - 27 Jul 2005 04:26 GMT
Hello,
I'm trying to write a macro that will toggle text in a bookmark between
hidden and unhidden using a checkbox. I still need the text visible on
screen, but I just don't want the text to print. I managed to make it work
one time, but something must have gone wrong in my code. Does anyone have a
better suggestion or can spot what I'm doing wrong. My macro is below.

Sub mcr1A()

ActiveDocument.Unprotect Password:=""

Set vCheck1 = ActiveDocument.FormFields("chk1A").Range

If vCheck1 = False Then
   ActiveDocument.Bookmarks("bk1A").Select
   With Selection.Font
       .Hidden = True
   End With
   End If

ActiveDocument.Protect Password:="", NoReset:=True, Type:= _
       wdAllowOnlyFormFields

End Sub
Doug Robbins - 27 Jul 2005 04:53 GMT
You don't say what doesn't work any more.  Maybe the problem is with the
settings under Tools>Options>View or Tools>Options>Print which are what
control the display/printing of hidden text.

I don't see anything wrong with your code, but better to use

ActiveDocument.Bookmarks("bk1A").Range.Font.Hidden = True

as it does not require the movement of the insertion point.

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

> Hello,
> I'm trying to write a macro that will toggle text in a bookmark between
[quoted text clipped - 21 lines]
>
> End Sub
Dave - 28 Jul 2005 01:12 GMT
Thanks Doug!! I should have elaborated.
When this macro is ran, the font does not change to hidden.
Seems like the problem is this line of code:
Set vCheck1 = ActiveDocument.FormFields("chk1A").Range

When I add a break to the code following this line, the value of vCheck is
neither True or False. I'm new to the word programming, should I not have
this macro run on exit?

> You don't say what doesn't work any more.  Maybe the problem is with the
> settings under Tools>Options>View or Tools>Options>Print which are what
[quoted text clipped - 31 lines]
> >
> > End Sub
Doug Robbins - 28 Jul 2005 20:39 GMT
You need to use the following construction:

Set vCheck1 = ActiveDocument.FormFields("chk1A").CheckBox.Value

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

> Thanks Doug!! I should have elaborated.
> When this macro is ran, the font does not change to hidden.
[quoted text clipped - 41 lines]
>> >
>> > End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.