find and replace in word with format

dean.rogers

New Member
Joined
Apr 6, 2012
Messages
31
I am looking to use excel 07 vba to find and replace into word and apply bullet point formatting to specified text.

Here is an example of my code:


Code:
Dim wrdApp As Word.Application
Dim wrdDoc As Word.Document
Set wrdApp = CreateObject("Word.Application")
wrdApp.Visible = True
Set wrdDoc = wrdApp.Documents.Open("C:\Template\Word Template.docx")

Set wrdDocSelection = wrdApp.Selection
            
        With wrdDocSelection.Find
            .Text = "[city_names]"
            .MatchWholeWord = False
            .Replacement.Text = ActiveWorkbook.Sheets("Sheet2").Range("D3")
            .Execute , , , , , , , , , , wdReplaceAll
the way the data is currently mapped over to word is as such:
chicago;new york;san francisco;san diego;

So i would like to apply bullet formatting to the data as a whole, and then apply a search in replace for the semi-colon to be replaced by a paragraph mark which will cause it to add another bullet point for each city.
 

Forum statistics

Threads
1,086,116
Messages
5,387,921
Members
402,088
Latest member
poppa57

Some videos you may like

This Week's Hot Topics

Top