View Single Post
 
Old 05-26-2017, 09:08 AM
Dr. Z Dr. Z is offline Windows 10 Office 2010 64bit
Novice
 
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