dropdown choice unhide hidden text

P

puba

Hi. If "yes" is selected from dropdown list, a macro on exit should
unhide the hidden text of the document.

The dropdown list is called "noyes", and the macro is called "unhide".
The possible values of the dropdown list are only "yes" or "no", "no"
being the default.

The idea is to have a hidden paragraph appear if "yes" is answered.

I have read posts in this forum and tried to do it myself but without
success.

Thanks.
 
K

Keith

Puba,
I am a beginner with VBA as well, but I have created a document with
many hidden sections.

Could you elaborate on where you are having trouble? You say that you
have already created a dropdown list and the macro that will run 'on
exit' from the dropdown. Are you saying you need help getting this
'on exit' macro to work?

The big thing I did was use bookmarks. I have enclosed my Hide &
Unhide macros below. As this was a major issue for the whole document
and I was working with a form, I may have additional steps not
required by you.
=============================================================
Sub HideEmergencyAddendum()
'
' HideEmergencyAddendum Macro
' Macro recorded 12/08/2006 by Keith
'
' Unprotect the form so the macro can work.
ActiveDocument.Unprotect Password:=""

' Go to the Emergency Addendum Section
Selection.GoTo What:=wdGoToBookmark, Name:="SectionEmergencyAddendum2"

' Hide the section.
With Selection.Font
.Name = ""
.Hidden = True
End With

' Go back to the beginning of the document.
Selection.GoTo What:=wdGoToBookmark, Name:="CommonStart"

' Protect the form without resetting all of the fields.
If ActiveDocument.ProtectionType = wdNoProtection Then
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
End If
-------------------------------------------------------------------------------------------------------------------------
End Sub
Sub AddEmergencyAddendum()
'
' AddEmergencyAddendum Macro
' Macro recorded 12/08/2006 by Keith
'
' Unprotect the form so the macro can work.
ActiveDocument.Unprotect Password:=""

' Open the Emergency Addendum section by Showing all text (hidden and
unhidden - via Paragraph symbol).
ActiveWindow.ActivePane.View.ShowAll = Not
ActiveWindow.ActivePane.View.ShowAll

' Go to the Emergency Addendum Section
Selection.GoTo What:=wdGoToBookmark,
Name:="SectionEmergencyAddendum2"

' Unhide the section
With Selection.Font
.Name = ""
.Hidden = False
End With
Selection.Font.Name = ""

' Emergency Addendum is now visible - Close the Showing of all text
(hidden and unhidden - via Paragraph symbol).
ActiveWindow.ActivePane.View.ShowAll = Not
ActiveWindow.ActivePane.View. _
ShowAll

' Go back to the beginning of the Emergency Addendum Section.
Selection.GoTo What:=wdGoToBookmark, Name:="EmergencyStart"

' Protect the form without resetting all of the fields.
If ActiveDocument.ProtectionType = wdNoProtection Then
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
End If

End Sub
 
B

Bear

Puba:

Can you post your code?

You need to run an exit macro that evaluates the value of the dropdown list
and unhides the text. But you don't say how you plan to unhide the text.

Do you intend to toggle Show/Hide and just show the hidden text? Or do you
have a specific style whose definition you would change? How will you
identify which hidden text will be shown?

Bear
 
M

Mitch Pothen

Was anyone able to get code for this (the hide/show text based on a drop down)? Please post or email if you have it, thanks!!



david.chinel wrote:

RE: dropdown choice unhide hidden text
19-Jun-07

Puba

Can you post your code

You need to run an exit macro that evaluates the value of the dropdown list
and unhides the text. But you don't say how you plan to unhide the text

Do you intend to toggle Show/Hide and just show the hidden text? Or do you
have a specific style whose definition you would change? How will you
identify which hidden text will be shown

Bea

--
Windows XP, Word 2000

EggHeadCafe - Software Developer Portal of Choice
WPF DataGrid Custom Paging and Sorting
http://www.eggheadcafe.com/tutorial...f-32b2d802ae17/wpf-datagrid-custom-pagin.aspx
 
M

Mitch Pothen

Was anyone able to get the code for this? (show/hide text based on value in a drop down)



david.chinel wrote:

RE: dropdown choice unhide hidden text
19-Jun-07

Puba

Can you post your code

You need to run an exit macro that evaluates the value of the dropdown list
and unhides the text. But you don't say how you plan to unhide the text

Do you intend to toggle Show/Hide and just show the hidden text? Or do you
have a specific style whose definition you would change? How will you
identify which hidden text will be shown

Bea

--
Windows XP, Word 2000

EggHeadCafe - Software Developer Portal of Choice
WPF DataGrid Custom Paging and Sorting
http://www.eggheadcafe.com/tutorial...f-32b2d802ae17/wpf-datagrid-custom-pagin.aspx
 
M

Mitch Pothen

Did anyone get any code for this?



david.chinel wrote:

RE: dropdown choice unhide hidden text
19-Jun-07

Puba

Can you post your code

You need to run an exit macro that evaluates the value of the dropdown list
and unhides the text. But you don't say how you plan to unhide the text

Do you intend to toggle Show/Hide and just show the hidden text? Or do you
have a specific style whose definition you would change? How will you
identify which hidden text will be shown

Bea

--
Windows XP, Word 2000

EggHeadCafe - Software Developer Portal of Choice
WPF DataGrid Custom Paging and Sorting
http://www.eggheadcafe.com/tutorial...f-32b2d802ae17/wpf-datagrid-custom-pagin.aspx
 
M

macropod

Hi Mitch,

You don't need vba for this - you can do it with field coding, for example:
{IF{REF Dropdown1}= "Show" "Text to Show"}
All you need for this to work is:
1. The correct bookmarkname for the dropdown (I've assumed 'Dropdown1')
2. The correct dropdown condition (I've assumed 'Show')
3. Ensure the dropdown's 'calculate on exit' option is checked

Note: The field brace pairs (ie '{ }') for the above example are created via Ctrl-F9 - you can't simply type them or copy & paste
them from this message.

--
Cheers
macropod
[Microsoft MVP - Word]


in message news:[email protected]...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top