#1
|
|||
|
|||
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 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! |
#2
|
||||
|
||||
The short answer is no. You will need additional code to do this with a separate macro for each macrobutton field. But you can simplify it - see attached.
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#3
|
|||
|
|||
Quote:
I came across an idea concerning the bookmarks. Can I make a degenerate macro that will essential apply itself to the next bookmark in-text? So if I put the button at position... let's say line 32 and a bookmark is present at line 33 and 44; could the macro simply apply itself to the next available bookmark by line? Thank you again for your reply. It is much appreciated. |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
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 |
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 |
Unhide and Re-hide in Excel 2003 | thorgal67 | Excel | 1 | 07-16-2009 07:06 AM |