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.
Keith - 19 Jun 2007 21:19 GMT
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
Bear - 19 Jun 2007 21:55 GMT
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

Signature
Windows XP, Word 2000