Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
Victoria Victoria is offline
external usenet poster
 
Posts: 19
Default When a check box is checked a text box field will pop up automatic

Is there a way to have a text box field pop up when a check box is checked?

Example:

1. Please check the boxes that you would like to work on:

[check box] - Nursery
[check box] - Welcome Center
[check box] - Hospitality

Say the Nursery box is checked, is there a way to have something like this
pop up automatically:

Nursery - [text field]

So for example: the "text field" will be where the person would enter their
availability

  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default When a check box is checked a text box field will pop up automatic

It's a bit complicated and requires vba, however assuming 'Nursery' is a
checkbox 'Check1' and you have a bookmark placed where you want the field to
appear named 'Nursery'. The following macro run on exit from Check1 will
enter or remove a form field 'Nur1' according to the setting of Check1.
http://www.gmayor.com/installing_macro.htm

You will need similar macros with different bookmarks for each check box
that you wish to be associated with such a pop up field.


Sub ExitCHK1()
Dim bProtected As Boolean
'Unprotect the file
If ActiveDocument.ProtectionType wdNoProtection Then
bProtected = True
ActiveDocument.Unprotect Password:=""
End If
'Check whether Checkbox1 is checked
If ActiveDocument.FormFields("Check1").CheckBox.Value = True Then
'Trap the non-existence of field "Nur1"
On Error GoTo AddField:
'Check if there is a field already place and if so delete it
With Selection
.GoTo What:=wdGoToBookmark, Name:="Nur1"
.Delete Unit:=wdCharacter, Count:=1
End With
AddField: 'Locate the field position bookmark and add a form field "Nur1"
With Selection
.GoTo What:=wdGoToBookmark, Name:="Nursery"
.FormFields.Add Range:=Selection.Range, Type:= _
wdFieldFormTextInput
.PreviousField.Select
End With
Selection.FormFields(1).Name = "Nur1"
GoTo Finished:

Else 'Checkbox is unchecked
On Error GoTo CleanUp: 'There is no field so finish and reprotect the form
'Remove the form field if it exists
With Selection
.GoTo What:=wdGoToBookmark, Name:="Nur1"
.Delete Unit:=wdCharacter, Count:=1
End With
End If
CleanUp:
'Goto the next field - here check box 2
Selection.GoTo What:=wdGoToBookmark, Name:="Check2"
'Reprotect the document.
Finished:
If bProtected = True Then
ActiveDocument.Protect _
Type:=wdAllowOnlyFormFields, NoReset:=True, Password:=""
End If
End Sub


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org


Victoria wrote:
Is there a way to have a text box field pop up when a check box is
checked?

Example:

1. Please check the boxes that you would like to work on:

[check box] - Nursery
[check box] - Welcome Center
[check box] - Hospitality

Say the Nursery box is checked, is there a way to have something like
this pop up automatically:

Nursery - [text field]

So for example: the "text field" will be where the person would enter
their availability



  #3   Report Post  
Posted to microsoft.public.word.docmanagement
Victoria Victoria is offline
external usenet poster
 
Posts: 19
Default When a check box is checked a text box field will pop up autom

So will I need to change the verbiage on the macro you gave me below for each
pop-up?

Meaning, everywhere you have NUR1, I need to change this to a new name per
checkbox?


"Graham Mayor" wrote:

It's a bit complicated and requires vba, however assuming 'Nursery' is a
checkbox 'Check1' and you have a bookmark placed where you want the field to
appear named 'Nursery'. The following macro run on exit from Check1 will
enter or remove a form field 'Nur1' according to the setting of Check1.
http://www.gmayor.com/installing_macro.htm

You will need similar macros with different bookmarks for each check box
that you wish to be associated with such a pop up field.


Sub ExitCHK1()
Dim bProtected As Boolean
'Unprotect the file
If ActiveDocument.ProtectionType wdNoProtection Then
bProtected = True
ActiveDocument.Unprotect Password:=""
End If
'Check whether Checkbox1 is checked
If ActiveDocument.FormFields("Check1").CheckBox.Value = True Then
'Trap the non-existence of field "Nur1"
On Error GoTo AddField:
'Check if there is a field already place and if so delete it
With Selection
.GoTo What:=wdGoToBookmark, Name:="Nur1"
.Delete Unit:=wdCharacter, Count:=1
End With
AddField: 'Locate the field position bookmark and add a form field "Nur1"
With Selection
.GoTo What:=wdGoToBookmark, Name:="Nursery"
.FormFields.Add Range:=Selection.Range, Type:= _
wdFieldFormTextInput
.PreviousField.Select
End With
Selection.FormFields(1).Name = "Nur1"
GoTo Finished:

Else 'Checkbox is unchecked
On Error GoTo CleanUp: 'There is no field so finish and reprotect the form
'Remove the form field if it exists
With Selection
.GoTo What:=wdGoToBookmark, Name:="Nur1"
.Delete Unit:=wdCharacter, Count:=1
End With
End If
CleanUp:
'Goto the next field - here check box 2
Selection.GoTo What:=wdGoToBookmark, Name:="Check2"
'Reprotect the document.
Finished:
If bProtected = True Then
ActiveDocument.Protect _
Type:=wdAllowOnlyFormFields, NoReset:=True, Password:=""
End If
End Sub


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org


Victoria wrote:
Is there a way to have a text box field pop up when a check box is
checked?

Example:

1. Please check the boxes that you would like to work on:

[check box] - Nursery
[check box] - Welcome Center
[check box] - Hospitality

Say the Nursery box is checked, is there a way to have something like
this pop up automatically:

Nursery - [text field]

So for example: the "text field" will be where the person would enter
their availability




Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
do not check spelling and grammar is automatically checked Technical Misfit Microsoft Word Help 4 January 18th 17 07:23 AM
keeping checked check boxes raptyrred Microsoft Word Help 1 June 28th 07 05:50 PM
How do I format a check box to be checked when double clicked? CJ Microsoft Word Help 2 January 18th 06 10:20 PM
Why does the custom dictionary check box not stay checked? rj Microsoft Word Help 0 September 30th 05 11:33 PM
Hightlite a check box when the checkbox is checked manny Microsoft Word Help 0 August 8th 05 09:39 AM


All times are GMT +1. The time now is 06:37 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"