Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-19-2021, 06:01 PM
Shhh Shhh is offline Command for repeating content control Windows 10 Command for repeating content control Office 2016
Novice
Command for repeating content control
 
Join Date: Jun 2021
Posts: 3
Shhh is on a distinguished road
Question Command for repeating content control

Hola! I found a macro on here that works beautifully to clear content control. Only if the repeating content control is removed :S When the repeating content control is added, an error pops up with "Debug" and the aCC.Range.Text = "" is no longer valid.

Wondering, how does one write to add the repeating content control? Any help is greatly appreciated!

This is the original code:

Dim aCC As ContentControl
For Each aCC In ActiveDocument.ContentControls
aCC.Range.Select
If aCC.Type <> wdContentControlDropdownList Then
aCC.Range.Text = ""
Else
aCC.Type = wdContentControlText
aCC.Range.Text = ""
aCC.Type = wdContentControlDropdownList
End If


Next aCC
End Sub
Reply With Quote
  #2  
Old 06-20-2021, 02:35 AM
Guessed's Avatar
Guessed Guessed is offline Command for repeating content control Windows 10 Command for repeating content control 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

Try this - it does nothing to some of the CC types such as Repeating CCs
Code:
Sub ResetCCs()
  Dim aCC As ContentControl
  For Each aCC In ActiveDocument.ContentControls
    Select Case aCC.Type
      Case wdContentControlComboBox, wdContentControlDate, wdContentControlRichText, wdContentControlText
        aCC.Range.Text = ""
      Case wdContentControlDropdownList
        aCC.Type = wdContentControlText
        aCC.Range.Text = ""
        aCC.Type = wdContentControlDropdownList
    End Select
  Next aCC
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia

Last edited by Guessed; 06-20-2021 at 06:09 PM. Reason: Fixed code error on Select Case line
Reply With Quote
  #3  
Old 06-20-2021, 06:26 AM
Shhh Shhh is offline Command for repeating content control Windows 10 Command for repeating content control Office 2016
Novice
Command for repeating content control
 
Join Date: Jun 2021
Posts: 3
Shhh is on a distinguished road
Default

Thank you for your response, Guessed!! it is your response from another user where i got the clear form thread from

I've tried the new one and still get the same "Range" isn't valid.

I've attached a sample I'm working with. Any suggestions is greatly appreciated!!
Attached Files
File Type: docm OT Form - Repeating Section.docm (48.1 KB, 9 views)
Reply With Quote
  #4  
Old 06-20-2021, 06:11 PM
Guessed's Avatar
Guessed Guessed is offline Command for repeating content control Windows 10 Command for repeating content control 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

Whoops, I left in an error on the Select Case line

Try it again after stopping that line at
Select Case aCC.Type

I've amended the code in the earlier post so you can use that as a block if you prefer
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #5  
Old 06-20-2021, 08:00 PM
Shhh Shhh is offline Command for repeating content control Windows 10 Command for repeating content control Office 2016
Novice
Command for repeating content control
 
Join Date: Jun 2021
Posts: 3
Shhh is on a distinguished road
Default

Thank you, Guessed!!! Thank you!!!
Reply With Quote
Reply

Tags
command button, macro, word 16

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Command for repeating content control Change Value of a Content Control based on the value of another content Control jsc_msoffice Word VBA 2 05-21-2021 09:51 PM
Command for repeating content control Content Control Dropdowns - How to duplicate the content control and allow a second choice ashleyf Word VBA 2 03-19-2020 09:11 AM
Command for repeating content control Repeating part of a Content Control NicB Word 9 07-29-2018 09:46 AM
Adding Row with Content control using Command Button baes10 Word VBA 0 12-13-2017 11:30 AM
Command for repeating content control Deleting a table from a content control -- preserving the content control BrainSlugs83 Word Tables 8 11-14-2013 03:06 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:32 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