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.
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"

Forum statistics

Threads
1,214,591
Messages
6,120,429
Members
448,961
Latest member
nzskater

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top