Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 11-26-2025, 06:37 PM
dpdalton dpdalton is offline Windows 11 Office 2021
Novice
How to create a "sort of" TOC for Word Document containing copied Macros
 
Join Date: Nov 2025
Posts: 2
dpdalton is on a distinguished road
Default How to create a "sort of" TOC for Word Document containing copied Macros

Before I retired a few years back, I pasted a copy of the text of all my accumulated macros (~120) into a single Word document (@10 pt type & ss, it's 218 pages long) . . . just in case I might ever need any of that in the future. Since then, I haven't used most of those old macros, but there are several of them that I still use pretty regularly, as well as a few others I use occasionally.

Just a few days ago, I opened Word to create a new document, pasted some copied text into it, then clicked on the Macro Dialog Box to run one of my macros on that text and discovered that none of my macros was listed. So I opened a few of my earlier documents - no macros listed in any of them. Next, I opened Normal.dotm separately - no macros listed. So I contacted MS Support & spent hours with them (including granting them remote access). They couldn't find my macros or explain why they were gone except to say that maybe Normal.dotm had been overwritten, perhaps by an Update, so he did a System Restore to go back to several days ago. Nope. MS says they're all irretrievably just gone.

So now I CAN make use of that macro document I created by copying the text for just the macros I want into the macro editor, save that document, & then the macros should be saved in my new Normal.dotm.

Of course, that document is just a lot of sequential lines of copied macro text. While I know I can manually find and copy each macro I want when I need it, it occurred to me that it will be easier to find them if I can add a sort of TOC at the beginning of this document that will list all of these macros by name with a hyperlink to the beginning of each macro. That way, I can click on it & be taken to the beginning of it, then copy just that macro text, then paste it into the Macro Editor.

However, I've never done TOCs at all (that may not be the right tool anyway) and not a lot with bookmarks, but it seemed like creating bookmarks at the beginning of each macro would be a way to start, but finding the starting spot for each 120 times seemed like a lot of work. Luckily, I found an example macro by Macropod that looked like it would do that for me (it's at https://www.msofficeforums.com/word-...bookmarks.html), so now I've created a bookmark at the initial text ("Sub") of each macro.* Those bookmarks are named "_Sub001" through "_Sub120". The next step would be the list (and I don't know how to do that either), but I now realize that a list of those bookmark names isn't going to be very helpful, anyway. So, in addition to TOC maybe not being the right tool, inserting bookmarks may also be the wrong starting point.

Anyway, now I realize I can't figure out how to make this all happen as I'd like, so I'm hoping someone here can tell me how I can automate this to end up with a page (or 2) at the beginning of this document that lists just the names of these macros, with each having a hyperlink that will take me to the beginning of that macro text.



Of course, the name of each macro follows the "Sub " text on that same line [e.g., "Sub ThreeSpaceFix()" ], so that's the name I'd like to have appear as the hyperlink text on the list. Maybe something that goes to each bookmark I've placed, then copies the rest of the line (preferably without the "()" at the end)? But doing that is beyond my (mostly Find/Replace) macro skills.

Any thoughts, suggestions, . . . help?

Thanks in advance!

* Before I could use Macropod's bookmark macro, I used Find/Replace to apply a unique character style to each occurrence of "Sub " [but only where it appears at the beginning of each macro, as there's also "End Sub" text in each]. Once I applied that unique style to each macro, it worked great.

Also, all this made me wonder why is there not a "macro backup" feature in Word to help prevent this sort of complete loss of macros? I feel lucky for having created that document back "when".

(FWIW: Win 11 & "Microsoft 365 Apps for Business" subscription)
Reply With Quote
 

Tags
list, macros, toc

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Preventing "Keep the last item you copied" popup on exit gogreen Word 0 09-15-2019 03:48 PM
How to create a "Font color" button and a "Highlight text" button in the Quick Launch toolbar ? gloub Word 12 02-19-2019 03:19 PM
Combine "sort within groups" and "identify duplicate/unique values" in two different variables. civilcervant Excel 3 06-12-2017 07:27 AM
How to create a "sort of" TOC for Word Document containing copied Macros How do I stop option for "new blog post" appearing when I create a new Word document? Kimu Word 3 10-27-2014 02:58 AM
Word crashing on "sort" routine Kayale Word 0 04-12-2010 04:54 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:57 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