Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 08-11-2022, 02:14 PM
DMSI DMSI is offline Add content control to all words from an Excel list in a Word document Windows 10 Add content control to all words from an Excel list in a Word document Office 2016
Novice
Add content control to all words from an Excel list in a Word document
 
Join Date: Aug 2022
Posts: 4
DMSI is on a distinguished road
Default Add content control to all words from an Excel list in a Word document

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.
Reply With Quote
 



Similar Threads
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
Add content control to all words from an Excel list in a Word document Push Word content control data and excel cells 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

Other Forums: Access Forums

All times are GMT -7. The time now is 07:53 PM.


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