Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-28-2020, 04:02 PM
Peterson Peterson is offline How to loop through content controls; if has text and has track changes, then accept Windows 10 How to loop through content controls; if has text and has track changes, then accept Office 2019
Competent Performer
How to loop through content controls; if has text and has track changes, then accept
 
Join Date: Jan 2017
Posts: 141
Peterson is on a distinguished road
Default How to loop through content controls; if has text and has track changes, then accept

I need to create a macro that will loop through all stories; in each story, I need to loop through all of the content controls with text. If the control contains a tracked change, then accept the change.


But I'm stuck at this point:
Code:
Sub ContentControlRevisions_Accept()
  
    Dim objCC As ContentControl
    Dim rngStoryRange As Range
  
    For Each rngStoryRange In ActiveDocument.StoryRanges
    
        For Each objCC In Rng.ContentControls
      
            'If the content control type is text

                ' If the content control contains track changes Then
            
                ' ...accept the track changes in the content control
                
                End If
      
            End If
    
        Next objCC
  
    Next rngStoryRange
  
 End Sub
How can I identify if the content control as track changes? Or am I doing this backwards, and I need to loop through all track changes and determine if any have some sort of content control attribute?


Thanks
Reply With Quote
  #2  
Old 07-28-2020, 05:55 PM
Guessed's Avatar
Guessed Guessed is offline How to loop through content controls; if has text and has track changes, then accept Windows 10 How to loop through content controls; if has text and has track changes, then accept Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,932
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Don't overthink it if you are going to accept them all anyway. Accepting revisions when there are no revisions is faster than testing to see if there are revisions before accepting.
Code:
Sub AcceptCCTracks()
  Dim aCC As ContentControl, aRng As Range
  For Each aRng In ActiveDocument.StoryRanges
    For Each aCC In aRng.ContentControls
      aCC.Range.Revisions.AcceptAll
    Next aCC
  Next aRng
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #3  
Old 07-28-2020, 08:16 PM
Peterson Peterson is offline How to loop through content controls; if has text and has track changes, then accept Windows 10 How to loop through content controls; if has text and has track changes, then accept Office 2019
Competent Performer
How to loop through content controls; if has text and has track changes, then accept
 
Join Date: Jan 2017
Posts: 141
Peterson is on a distinguished road
Default

Thank you so much, Andrew -- I appreciate it!
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Loop through controls, make certain controls invisible MacroWizard Word VBA 2 11-10-2015 02:36 PM
Loop and Update Content Controls with value vss712 Word VBA 7 08-27-2015 08:56 PM
How to loop through content controls; if has text and has track changes, then accept Rich text/Plain text Content Controls in Template michael.fisher5 Word 9 11-19-2014 06:36 AM
How to loop through content controls; if has text and has track changes, then accept Moving between Rich text content controls Sammie0Sue Word 4 03-12-2014 01:43 AM
How to loop through content controls; if has text and has track changes, then accept Rich Text Content Controls: Formatting? tinfanide Word VBA 8 03-04-2013 04:15 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:58 PM.


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