View Full Version : Code to find a specific word and insert a Content control
scopley
06-17-2014, 08:09 AM
I'm trying to write a macro that will search my word document for a specific word and when found will either replace the word with a content control drop down list or insert the content control after the specific word. Is this possible?
gmaxey
06-17-2014, 03:29 PM
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim oRng As Word.Range
Dim oCC As ContentControl
Set oRng = ActiveDocument.Range
With oRng.Find
.Text = "Kafilterfish"
While .Execute
oRng.Delete
Set oCC = ActiveDocument.ContentControls.Add(wdContentControlDropdownList, oRng)
oRng.Collapse wdCollapseEnd
Wend
End With
lbl_Exit:
Exit Sub
End Sub
scopley
06-18-2014, 07:01 AM
Thank you! Thank you!
scopley
06-18-2014, 07:26 AM
Ok, one last question... how can I highlight the text in the content control list after creating it?
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.