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

Re: Hidden Text Using Checkbox by Doug

Doug
Tue Jul 26 22:53:03 CDT 2005

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.

--
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
"Dave" <Dave@discussions.microsoft.com> wrote in message
news:DE3CDA38-DCB0-4884-92B9-B025A3B210E1@microsoft.com...
> 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
>
>
>



Re: Hidden Text Using Checkbox by Dave

Dave
Wed Jul 27 19:12:03 CDT 2005

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?

"Doug Robbins" wrote:

> 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.
>
> --
> 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
> "Dave" <Dave@discussions.microsoft.com> wrote in message
> news:DE3CDA38-DCB0-4884-92B9-B025A3B210E1@microsoft.com...
> > 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
> >
> >
> >
>
>
>

Re: Hidden Text Using Checkbox by Doug

Doug
Thu Jul 28 14:39:32 CDT 2005

You need to use the following construction:

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


--
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
"Dave" <Dave@discussions.microsoft.com> wrote in message
news:5B7CF75C-69B7-466F-A249-D66E6FAFE9A3@microsoft.com...
> 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:
>
>
> 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?
>
> "Doug Robbins" wrote:
>
>> 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.
>>
>> --
>> 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
>> "Dave" <Dave@discussions.microsoft.com> wrote in message
>> news:DE3CDA38-DCB0-4884-92B9-B025A3B210E1@microsoft.com...
>> > 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
>> >
>> >
>> >
>>
>>
>>