# Word VBA - changing the style of a paragraph mark



## Andrew Fergus (Jun 13, 2013)

Hello

I'm a little bit out of my depth here and I'm looking for some help with Word VBA. I have a paragraph mark for which I need to change the style from "Heading 3" to "Normal".

The text flows as follows:

Normal text in normal style (CR)
(PM)
New Heading in Heading 3 style (CR)

where:
(CR) = carriage return or some such thing (i.e. the little arrow that drops down and left; it can be input using Alt 011)
(PM) = paragraph mark where the style is "Heading 3" (it looks like a backwards 'P' when you unhide the hidden characters)

Through VBA I can find the paragraph mark that has the style "Heading 3" but I need to change this to a "Normal" style, without changing the style of the line below.

To date all of my coding attempts have failed, these include selecting just the (PM) line and trying to set the style using a command like this:

Selection.Style = ActiveDocument.Styles("Normal")

I have also tried selecting the entire (PM) line as well as the entire line above and setting the style using the same command, to no avail. I have also tried setting the style to an intermediate style like "Heading 2" and then re-setting to "Normal" - again the style change doesn't work. I have also tried to brute force it with a command like this:

Selection.Style = "Normal"
again, it doesn't work.

Whilst I can re-set the style manually in the Word document, I can't get a macro to do this - given the document has hundreds of pages and I don't know how many stray paragraph marks there are, I think a macro is my only option - unless someone has another method? Any help with setting the style of the paragraph mark to "Normal" using VBA would be appreciated. I have spent way too long on this and it feels like it should be very easy!

Thanks in advance
Andrew


----------



## Andrew Fergus (Jun 14, 2013)

Ok, I have (kind of) solved this so will post a solution for anyone who may stumble upon this thread.....it's a bit of a work-around that addresses the symptom not the cause....

Try what I may I couldn't set the style, but given the text always followed the format of:

some text in normal style, carriage return, paragraph mark, and some more text in heading 3 style

I solved this by adding another CR and PM before the first CR, then deleting the CR and PM that had the incorrect style.
The new CR and PM automatically pick up the correct style from the first block of text.  Solved!

Andrew


----------



## Cindy Ellis (Jun 14, 2013)

Hi Andrew,
If all Heading 3's needed to be changed to normal, you could possibly have used Find&Replace (without VBA), replacing only the format. If it was just some of the heading 3 paragraphs, though, you pattern matching was probably your best option.
Cindy


----------



## Marbles (Jun 15, 2013)

Andrew

A carriage return in Word is a new paragraph.  What you are using as the carriage return, is a new line in the same paragraph.  It might make a difference when formatting paragraphs.

Alan


----------

