Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 05-26-2017, 09:08 AM
Dr. Z Dr. Z is offline Macro to hide/unhide text to call variable bookmarks Windows 10 Macro to hide/unhide text to call variable bookmarks Office 2010 64bit
Novice
Macro to hide/unhide text to call variable bookmarks
 
Join Date: May 2017
Posts: 2
Dr. Z is on a distinguished road
Default Macro to hide/unhide text to call variable bookmarks


Howdy,

What I want to do:
Create a button on a MS word document that when clicked will show/hide text.

What I did:
1. created a button using the macro {Macrobutton Mymacro Show/Hide}

2. Bookmarked series of text under "bookmark1", "bookmark2", etc.

3. I can create a macro for each bookmarks:
Code:
Sub MYMACRO()
ActiveDocument.Bookmarks(bookmark1).Range.Font.Hidden = Not ActiveDocument.Bookmarks(bookmark1).Range.Font.Hidden
End Sub
This is very crude but I am not a full-time programmer.

My question:
Instead of creating a macro for each bookmark, is there a way for the macro to act as a function and with a variable?

What I want to do is basically make a variable macro, make the macrobutton call to a specific bookmark and have the macro be applied to that bookmark. Instead of writing a different macro with a different bookmark each time, I just want to create a button that will apply the macro to the variable bookmark called each time.

The final purpose is to show/hide 200 pages of text into 50.

I attached an example of what I have done.
I was wondering if it was possible to make OBERON's speech hidden on button toggle without having to write a new line of macro code.

Cheers!
Attached Files
File Type: docm MS Word Spoiler example.docm (21.2 KB, 20 views)
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to hide/unhide text to call variable bookmarks Hide / unhide Rows NullVBA Excel Programming 4 12-09-2015 05:10 AM
Hide/Unhide Text Based on Drop Down Selection gw1500se Word 3 02-19-2015 12:17 PM
Macro to hide/unhide text to call variable bookmarks Hide/Unhide a Block of Text Based on Choice Selection inquirer Word VBA 7 09-22-2014 04:41 PM
Hide/Unhide pictures maloneb PowerPoint 1 01-18-2012 03:34 PM
Macro to hide/unhide text to call variable bookmarks Unhide and Re-hide in Excel 2003 thorgal67 Excel 1 07-16-2009 07:06 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:00 PM.


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