View Single Post
 
Old 05-19-2023, 08:54 AM
VBAadvocate VBAadvocate is offline Windows 10 Office 2019
Novice
 
Join Date: Feb 2022
Posts: 12
VBAadvocate is on a distinguished road
Default

Easier than I thought. I think this works but maybe there will be a catch, somehow.

Code:
Sub CheckIfTOC_Changed()
    Dim rng As Range
    Dim strBefore As String
    Dim strAfter As String
    
    Set rng = ActiveDocument.TablesOfContents(1).Range
    strBefore = rng.Text
    ActiveDocument.TablesOfContents(1).Update
    Set rng = ActiveDocument.TablesOfContents(1).Range
    strAfter = rng.Text
    
    If strBefore = strAfter Then
        MsgBox "No change"
    Else
        MsgBox "Changed"
    End If
    
End Sub
Reply With Quote