Toggle Track Changes Word Documents using VBA

Toggle Track Changes Word Documents using VBA

Track changes

Track changes a review feature offered by Microsoft Word document. Turning on Track Changes gives you and your coworkers a way to make changes that are easy to spot. The changes are like suggestions that you can review, and then remove them or make them permanent.

Code example

Public Sub TrackChangesOnOffExample()
On Error Goto errh
	'Folder picker dialog
	With Application.FileDialog(msoFileDialogFolderPicker)
		.Title = "Select a folder..."
		.Show
		'Validate selection
		If .SelectedItems.Count = 0 Then
			Exit Sub
		Else
			myFolder = .SelectedItems.Item(1)
		End If
	End With
	'Show dialog
	frmChoise.Show
	'Add file filter
	myWildCard = "*.doc"
	'build path with bild card
	myDocs = Dir(myFolder & "\" & myWildCard)
	
	While myDocs <> ""
		Dim doc As Document
		Set doc = Documents.Open(FileName:=myFolder & "\" & myDocs, ConfirmConversions:=False)
		ToggleTrackChanges doc
		doc.Close SaveChanges:=True
		myDocs = Dir()
		Set doc = Nothing
	Wend
	
	MsgBox "Processing Complete"
errh:
	If err.Number<>0 Then
		MsgBox "Processing Error"
	End If
End Sub

ToggleTrackChanges Method Code

Sub ToggleTrackChangesInDocument(oDocument As oDocumentument)
	'Toggle track revisions
    oDocument.TrackRevisions = Not oDocument.TrackRevisions
	'Toggle Track Formatting
    oDocument.TrackFormatting = Not oDocument.TrackFormatting
	'Toggle Track Moves
    oDocument.TrackMoves = Not oDocument.TrackMoves
	
	Set oDocument=Nothing
End Sub

Please leave your comments or queries under comment section also please do subscribe to out blogs to keep your self upto date.

Leave a Reply

Your email address will not be published.