![]() |
#1
|
|||
|
|||
![]()
Hi all,
I hope you are well. I have a word file with a Rich text content control whose title is "Name", I tried to create a macro to tell whether or not there is data in the Rich text content control. However, it doesn´t work as it always says that the Content control has data. Anyone can help me set up this macro so it says “Content control name is empty” when there is no data in it? Or “Content control name has data” Thanks Code:
Sub CheckContentControl() Dim ctnControl As ContentControl Dim isEmpty As Boolean Set ctnControl = ActiveDocument.ContentControls("Name") If ctnControl Is Nothing Then MsgBox "Content control 'Name' not found.", vbExclamation Exit Sub End If isEmpty = Len(ctnControl.Range.Text) = 0 If isEmpty Then MsgBox "Content control 'Name' is empty.", vbInformation Else MsgBox "Content control 'Name' has data.", vbI Nformation End If End Sub |
Thread Tools | |
Display Modes | |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Use VBA to show text when content control check box is checked | kvrieze | Word VBA | 1 | 08-19-2023 03:11 AM |
MsgBox launch when a Check Box Content Control is clicked | wolfgrrl | Word VBA | 1 | 06-21-2019 12:13 PM |
![]() |
Strogg | Word | 3 | 02-10-2019 11:45 AM |
Check Box Content Control when checked users are presented with an option | cryder | Word | 0 | 01-07-2016 05:11 AM |
![]() |
canadansk | Word VBA | 5 | 04-01-2015 08:21 AM |