Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 02-22-2015, 11:27 PM
gmayor's Avatar
gmayor gmayor is offline When content controls are deleted, my macro does not work as I would like. Windows 7 64bit When content controls are deleted, my macro does not work as I would like. Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,144
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

The problem is that you are counting controls to determine which column to fill. The macro has no way of knowing that you have removed a control so it works on the basis that the new count is correct. You need to address the controls by name and fill the column related to that control name e.g.

Code:
        For Each CCtrl In .ContentControls
            Select Case CCtrl.Title
                Case "Title1": WkSht.Cells(i, 1) = CCtrl.Range.Text
                Case "Title2": WkSht.Cells(i, 2) = CCtrl.Range.Text
                    'etc
            End Select
        Next oCC
This will mean that you will have to add names to the CCs before they are filled by your users.
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
When content controls are deleted, my macro does not work as I would like. VBA to set Content controls as non printing Sammie0Sue Word VBA 21 01-12-2021 04:44 PM
When content controls are deleted, my macro does not work as I would like. Cant type into content controls in a form after protecting document using macro rgburridge Word VBA 4 01-27-2015 02:37 PM
Word 2010 Macro Enabled Template with Content Controls keen1598 Word VBA 7 01-29-2014 03:17 PM
When content controls are deleted, my macro does not work as I would like. Content Controls Sammie0Sue Word 6 11-06-2013 10:56 PM
Macro to link 2 content controls bortonj88 Word VBA 2 08-21-2012 06:24 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:59 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft