Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-19-2023, 08:45 AM
VBAadvocate VBAadvocate is offline How to know if TOC changed after update Windows 10 How to know if TOC changed after update Office 2019
Novice
How to know if TOC changed after update
 
Join Date: Feb 2022
Posts: 12
VBAadvocate is on a distinguished road
Default How to know if TOC changed after update

I would like to know if my TOC changed after I update it with the following:

ActiveDocument.TablesOfContents(1).Update

Perhaps something like saving a copy of the range before updating and compare the saved range with the range after the update.



Is there an easy and simple way to do this?
Reply With Quote
  #2  
Old 05-19-2023, 08:54 AM
VBAadvocate VBAadvocate is offline How to know if TOC changed after update Windows 10 How to know if TOC changed after update Office 2019
Novice
How to know if TOC changed after update
 
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
Reply

Tags
compare, toc update



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to know if TOC changed after update Update all fields won't update index! Ryhne Word VBA 4 04-23-2020 04:49 AM
Unit is $, should be € - why is it being changed? Officer_Bierschnitt PowerPoint 2 01-14-2016 03:04 AM
Formatting has changed? Colonel Biggs Word 3 03-13-2015 09:14 PM
Update a summary chart when I update a dashboard with dates cangelis Excel 6 09-24-2014 08:08 AM
How to know if TOC changed after update Update Outlook but user path changed Ossie1972 Outlook 1 12-08-2010 08:19 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:51 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft