Archive for February, 2022


Word: Deleting many unused styles at once

February 23, 2022

Today I went down the rabbit hole of how to delete hundreds of unused styles in a document. Deleting them manually, even using the Organizer (see my blog post on this:, is tedious, so I wanted to find if there was an easier way using a macro or similar.

Bottom line: It may be easier to use a macro or one of the other methods (1 to 4) described below if you have a fairly short and not terribly complex document. BUT if you have a large complex document (e.g. with control boxes for document properties, outline numbering, modified settings for inbuilt styles such as heading and TOC styles), you could be making more work for yourself than doing it manually, consider using the macro in Method 5 (added after this post was originally written). 

Test environment: I used a copy of a client’s 440p document, which had appendices, outline numbering, portrait/landscape sections, headers and footers, control boxes for doc properties that were repeated in the headers/footers, automated cross-references, automated caption numbering etc. It also had hundreds of styles, many of which seemed to be unused, that seemed to have come in from other documents or had been created for a specific need—it was these I was trying to get rid of quickly. I printed the list of styles to PDF—this document was 129p long!

My Google searching led me to a couple of sites and forums that seemed to address this issue, a couple of which used macros to achieve the task. One used a version of ‘maggying’ a document (named for the late Maggie Secara, after whom the technique is named), so I tried that first—why use brute force if something simple can achieve what you want?

Method 1: Maggie the document and put it into a new blank document

I found this method here: It seemed an ideal solution—quick and simple, with the outcome I wanted. However, it just didn’t work for me. After 45 minutes waiting for the copied text in the 440p document to paste, with ‘not responding’ in the title bar of Word, I finally killed the process. However, I haven’t written off this method as it could be a good solution for smaller documents with many styles. (See Method 4 for some issues I found using this method on a complex document.)

Method 2: Allen Wyatt’s macro

The next thing I tried was a macro from Allen Wyatt, the WordTips guy: From another forum I was aware that the header/footer styles might get removed using his macro, so I was ready to check that. However, I got ‘not responding’ in Word again, and after 40 mins waiting for something to happen, I killed the process again. This may be a solution for a smaller document, but didn’t work for me—I expect a macro to take a few minutes at most.

Method 3: Paul Edstein’s macro

The next macro was one from Paul Edstein (a variation of Allen Wyatt’s DeleteUnusedStyles macro) that I found here: Supposedly, this one didn’t remove header and footer styles, which are always listed as unused even when they are (yes, that’s Word being Word…). This one took about 25 mins to run on my 440p document, and the list of styles seemed to reduce. However, when I checked them, many of the unused styles were still listed and hadn’t been deleted at all. These styles were user-added (not inbuilt styles) and as far as I know, were not linked to other styles, though it’s difficult to tell what’s linked to what.

Method 4: Method 3 + Method 1

As a final test, I took the copy of the document I’d saved from Method 3 and ran Method 1 on it; that is, I ran Paul Edstein’s macro, then used the Maggie method to put the document into a new blank document.

This time the copied text (all 440p) pasted quickly (within a minute) and Word didn’t hang. However, all the unused styles still remaining after running the Method 3 macro were copied across, even though all indications are that they AREN’T used. But the resulting document had further issues that would have to be fixed manually. For example:

  • I lost the content in the doc control boxes for the doc #, doc title etc. in the headers/footers and main body of the document—the control boxes were still there, but the content was gone. These were easy enough to add back in by copy/pasting from the original document, but be aware that this content, if you use it, may disappear.
  • All style formatting for built-in styles such as Caption, TOC 1, TOC 2 etc. and Table of Figure styles was lost. I could easily import them back in using the Organizer. Heading 1, 2, 3 etc. had lost the outline numbering and instead had reverted to a different numbering schema, different fonts, different colours, etc. Again, I used the Organizer to reestablish these.

With these results, I didn’t bother checking any further.

Was this combined method worth it? No, because of the time taken in identifying and then fixing up the issues with the styles.


As a final note, when I printed the styles used in the doc (to PDF, NOT paper), the untouched original had 129p of style definitions listed. I fully expected this to be less after deleting all the unused styles using the methods listed here, but instead the PDF of the styles in the modified document (Method 4) ran to 143p!!! This PDF included the styles I’d manually deleted after checking there were unused. This matches the information I discovered as I was researching this, and that’s that the ‘in use’ styles are ANY styles ever used in the document, whether they are still in use or have been deleted.

There has to be an easier way that actually deletes all the unused styles and that doesn’t create even more work or take time that could be used manually deleting them. And Microsoft needs to look at why ‘in use’ styles include ANY styles EVER used in the document, even after they’ve been deleted—‘in use’ to me means ‘being used right now’, not was used 5 years ago on an older template.

Update 25 Feb 2022: One of the commentators on this post shared another macro, which, after some tweaking (because WordPress changes things like plain quote to smart quotes, hyphens/dashes, underscores and totally removes angle brackets, etc.), I got to work on my long document. I’ve added it as Method 5.

Method 5: Simon Jones’ macro

This macro has two parts—first it identifies how many styles are in-built and how many are custom (user-added). Once it’s done that, you are asked to click Yes or No to continue to delete the unused custom styles. In my test document, this part of the macro identified almost 900 (!!!!) custom styles.

Message box telling me that there were 897 custom styles used in the document, and 374 in-built styles

After the macro had run (and it took about 30 minutes to run on the 440p document—an acceptable time, in my opinion), I was left with 38 custom styles that were used in the document. A much more manageable list!

Message after the first part of the macro ran saying there were 38 custom styles remaining in the document

Notes about this macro:

  • If you’re using a version of Word prior to Word 2007, you will have to comment out the lines that have ### in them.
  • Copy/paste this macro—some of it goes off the visible window


Sub DeleteUnusedStyles()
'Simon Jones, MillStream Designs Ltd, 05/03/2007
'macro originally called DeleteUnusedStylesTake3

Dim objStyle As Word.Style
Dim intBuiltInStyles As Integer
Dim intStyle As Integer
'Count the number of built-in styles in this document
For Each objStyle In ActiveDocument.Styles
    If objStyle.BuiltIn Then
        intBuiltInStyles = intBuiltInStyles + 1
    End If
Next objStyle
'Show summary and ask permission to continue
If MsgBox("There are " & intBuiltInStyles & " built-in styles " & vbCrLf & _
          "and " & ActiveDocument.Styles.Count - intBuiltInStyles & _
          " custom style(s) in this document." & vbCrLf & vbCrLf & _
          "Delete unused custom styles?", vbOKCancel + vbExclamation, _
          "Delete Unused Styles") = vbOK Then
    'OK to continue
    'Run through all the styles in the document BACKWARDS -
    'so we only delete styles from the end of the collection
    For intStyle = ActiveDocument.Styles.Count To 1 Step -1
        If Not ActiveDocument.Styles(intStyle).BuiltIn Then
            'This is a custom style
            'See if it is in use
            With ActiveDocument.Content.Find
                .Style = intStyle
                .Execute Format:=True
                If Not .Found Then
                    'Style is not in use
                    'We can delete it
                    With ActiveDocument.Styles(intStyle)
                        'If this style is linked to another we have to unlink them -
                        'otherwise both styles will be deleted which causes problems -
                        'this style may be linked to a built-in style which will cause -
                        'an error if we try to delete it.
                        If .Type <> wdStyleTypeCharacter Then
                            'Character styles can't be linked from, only linked to
                            'The Linked property only exists in Word 2007 and above -
                            'for previous versions, comment out the "If" and "End If" lines below
                            If .Linked Then   '### Word 2007+ only
                                'The LinkStyle property only exists in Word 2002 and above -
                                'for previous versions, comment out the lines below
                                If Not .LinkStyle Is ActiveDocument.Styles(wdStyleNormal) Then '### Word 2002+ only
                                   .LinkStyle = wdStyleNormal '### Word 2002+ only
                                End If       '### Word 2002+ only
                                'LinkStyle is a very badly behaved property and this is the -
                                'closest we can get to unlinking styles short of copying all -
                                'text except the last paragraph mark to a new document.
                            End If           '### Word 2007+ only
                        End If
                        'Ignore any error caused by trying to delete
                        'a style whose name begins with a space
                        On Error Resume Next
                        On Error GoTo 0
                    End With
                End If
            End With
        End If
    Next intStyle
    'Display summary
    MsgBox "There are " & ActiveDocument.Styles.Count - intBuiltInStyles & _
           " custom style(s) left in this document.", vbInformation, "Unused Styles Deleted"
End If
End Sub


[Links last checked February 2022]




Transfer speed affected by where you plug in the USB

February 17, 2022

I needed to transfer some files to a backup external hard disk drive (HDD). I plugged the HDD into a USB-3 hub and did the transfer, but I only got a transfer rate of ~36 MB per second. I knew the HDD had a higher maximum transfer speed than that, so I unplugged it from the USB hub (which was also linked to the back of my PC with about a 1.5 m USB extension cable), and plugged it directly into a USB-3 port on the front of the PC. The transfer speed immediately jumped to ~170 MB per second.

Same USB-3 cable, just a different USB port—one that was directly into the PC without going through a hub or using an extension cable.

Update: Simon commented below that a USB-2 device plugged into a USB-3 hub will limit all ports on the hub to USB-2 as well. Guess what many wireless devices like mice and keyboards are??? USB-2!


Delete specific browsing history in Chrome

February 9, 2022

Over our hot summer months, I’ve been staying inside in the cool doing family tree research and verifying source URLs in my family tree software. I’ve haunted the website and done thousands of searches looking for elusive family members and the official sources that verify their dates of birth, death, marriage etc. Today I decided to clear some of my browsing history, specifically for the Ancestry pages. But how to delete those I found? Well, there’s a trick, but it’s not obvious from the Chrome history page, which by default shows only 150 search results at a time, and seems to only allow you to click one checkbox at a time to select those to delete. Clicking one checkbox at a time was NOT a viable option for potentially thousands of pages.

Here’s how to bulk delete items from Chrome’s history:

  1. In Chrome, press Ctrl+h to open the history page.
  2. In the search box, type part of the URL and press Enter (in my case, I typed
  3. If you’ve been to that particular domain a lot, you’ll get a list of just 150 results even if there are many more stored by Chrome.
  4. Use the scrollbar to scroll down the list, then keep on scrolling. What this does is expands the 150 results to 300, 900, 1200, 1800 results, etc. (i.e. multiples of 150 or 300 results).
  5. When you stop scrolling and click back into the Chrome window, the number of results will be listed at the top of the results.
  6. Press Ctrl+a. This selects ALL the checkboxes for the number of results listed.
  7. Press Delete to delete them all. Confirm the deletion.
  8. Repeat these steps if you still have more, or do another search if you want to delete the browsing history for another domain.
  9. Close the History tab when you’ve finished.