PDA

View Full Version : Looking for VBA to show tracked changes and hide comments in Word Document



uougaard
02-03-2024, 03:31 AM
For many years we have had two VBA macros (called from buttons in a ribbon extension). One macro sets up the open document to show Tracked changes *and* comments, the other sets up the document to show only tracked changes but hides comments

The important lines of the macros are

ActiveWindow.View.ShowRevisionsAndComments = True;
ActiveWindow.View.ShowComments = False/True

With recent changes of the commenting features in Office/word, both macros show comments, and I cannot hide comments while seeing tracked changes with my VBA

My analysis show that the behaviour is linked to the new "show comments" button in the comments group in the Review tab.
This "Show Comments" button has two variants: "Contextual" or "List". when "show comments - Contextual" has been selected from the ribbon my original procedures work, but only until I close the document

it also seems that just using the "show comments" button once to turn off display of comments make our original procedures work.

I can not find a VBA method to do the "Show Comments - Contextual" function (and I am not sure what function is behind the button "Show comments - off"

macropod
02-08-2024, 06:09 AM
Cross-posted at: Looking for VBA to show tracked changes and hide comments (msofficeforums.com) (https://www.msofficeforums.com/word-vba/51997-looking-vba-show-tracked-changes-hide-comments.html)
Please read VBA Express' policy on Cross-Posting in Rule 3: http://www.vbaexpress.com/forum/faq.php?faq=new_faq_item#faq_new_faq_item3

Ezekiel Moen
04-01-2024, 01:49 AM
If you want to show only tracked changes and hide comments, you can use the following VBA code:

Sub ShowTrackedChangesOnly()
With ActiveWindow.View
.ShowRevisionsAndComments = True
.RevisionsView = wdRevisionsViewFinal
.ShowComments = False
End With
End Sub