Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 09-03-2018, 12:35 AM
macropod's Avatar
macropod macropod is offline Unhide pages with button Windows 7 64bit Unhide pages with button Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Your code is unlikely to work well with tables, floating graphics and the like. Moreover, toggling the Font.Hidden property prevents neither the visibility nor the printing of the affected range; those are both things that depend on how the end-user has Word configured. You might do better to put the content to be conditionally-displayed inside an IF field linked to a numeric custom document property. The fields might be coded as:
{IF{DOCPROPERTY Section1}= 1 "Conditional Section1 content goes here"}
{IF{DOCPROPERTY Section2}= 1 "Conditional Section2 content goes here"}
{IF{DOCPROPERTY Section3}= 1 "Conditional Section3 content goes here"}
where Section# is the custom document property's name.

Note: The field brace pairs (i.e. '{ }') for the above examples are all created in the document itself, via Ctrl-F9 (Cmd-F9 on a Mac); you can't simply type them or copy & paste them from this message. Nor is it practical to add them via any of the standard Word dialogues. The spaces represented in the field constructions are all required.

You could then use a macro as simple as:
Code:
Private Sub section1_Click()
With ActiveDocument
  With .CustomDocumentProperties("Section1")
    .Value = (.Value + 1) Mod 2
  End With
  .Fields.Update
End With
End Sub
to toggle the display for Section1 on/off.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
 

Tags
hide, macro, word2016



Similar Threads
Thread Thread Starter Forum Replies Last Post
Unhide pages with button Print only specified pages of word by 1 click of command button using vba Zhibek Word VBA 9 08-12-2018 11:44 PM
Cannot unhide rows in VBA RosieSummers Excel Programming 2 02-12-2018 12:47 AM
Unhide pages with button Button within Word to print certain pages hotcomper Word 1 08-10-2015 11:36 PM
A row that will not UNHIDE MaineLady Excel 0 11-23-2014 01:15 PM
Unhide pages with button document with 5 pages and a forward button rich_cirillo Word 3 05-06-2014 06:16 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:35 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft