![]() |
#1
|
|||
|
|||
![]()
Hello pretty new to VBA, been searching for a method to scan through an excel list and apply Content Controls to any words in that list. I found a similar thread on this site but it looks like it goes Word to Excel so I just need to try and build it the other way.
I currently have put together a macro from some I've found online which scans a document if it is in single or double brackets depending how I change the regex statement. Anyway wondering it would be possible to scan an excel list of 64 items and then scan the word document for those items and apply content controls if they exist. Current macro I have: Single Bracket content control Sub ReplaceTags() ' ' ReplaceTags Macro ' ' Dim myRange Set myRange = Application.ActiveDocument.Content Dim myFind Set myFind = myRange.Find With Selection.Find .ClearFormatting .Text = "(\[)(*)(\])" .Execute Forward:=True .MatchWildcards = True End With If Selection.Find.Found = True Then Selection.Range.ContentControls.Add (wdContentControlText) Selection.ParentContentControl.Tag = Selection.Text End If End Sub Sub ReplaceAllTags() ' ' ReplaceAllTags Macro ' ' For i = 0 To ActiveDocument.Words.Count Selection.EscapeKey Application.Run MacroName:="ReplaceTags" Next End Sub Now if anyone can point me to how to point this to an excel list and scan than then pass it through to the above functions that would be much appreciated. |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Import list from Excel into drop-down content control in word | shanshan89 | Word VBA | 10 | 08-11-2022 11:53 PM |
Populate Word content control fields with data from Excel | Kapluke | Word VBA | 8 | 01-10-2022 05:39 AM |
![]() |
shaztastic | Word VBA | 13 | 08-27-2018 06:46 AM |
Combo Box Content Control: How to update the list throughout the whole document? | deepak_fer | Word | 9 | 03-18-2018 04:10 AM |
Word 2010 Content Control help - Combo Boxes vs Drop Down List | proghy | Word | 1 | 09-16-2014 02:01 PM |