Results 1 to 5 of 5
  1. #1
    New Lounger
    Join Date
    Jul 2015
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Code to check for Track Changes and turn off

    I have a macro that runs when you save a document. It enters the documentID into the footer of the document.
    There is another macro that can be selected to remove the documentID. This also can be done when new versions are saved.
    I have a problem where the macro freezes or crashes word if track changes are on when a user saves or runs the remove macro.

    How can I add code to see if track changes is on, and if it is, turn it off, before inserting or removing the footer?

    Thank you for your help.
    Deanna

  2. #2
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,434
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    Deanna,

    Welcome to the Lounge as a New Poster!

    Here's some code you can run:
    Code:
    Option Explicit
    
    Sub Macro1()
    
      MsgBox "Track Changes is: " & IIf(ActiveDocument.TrackRevisions, "ON", "OFF")
      
    End Sub
    To test in a macro just use:
    Code:
    If ActiveDoucment.TrackRevisions then ActiveDocument.TrackRevisions = False
    HTH
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  3. The Following User Says Thank You to RetiredGeek For This Useful Post:

    LawTrain (2015-07-02)

  4. #3
    New Lounger
    Join Date
    Jul 2015
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Great! Thanks RG. I'm just learning all of this. So logical.
    Have a nice weekend.

  5. #4
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts
    Why do need to check? Unless you want to restore the previous state afterwards, you can simply turn it off, via ActiveDocument.TrackRevisions = False.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  6. #5
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,434
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    Paul,

    That is true. However, It can't hurt and can help as some settings I've run across will throw errors if you attempt to turn them off and they are not on. Of course, this may be just an Excel, where I do most of my VBA, problem. Better safe than sorry.
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •