PDA

View Full Version : Macro to clear formatting



liverpool
07-20-2009, 07:11 AM
Hi

I recoreded the following macro to clear the formatting of a piece of searched tag text. How do i get the macro to loop so it finds all occurences in the whole document.

Selection.Find.ClearFormatting
With Selection.Find
.Text = "\<\cf cstyle?*\>"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchKashida = False
.MatchDiacritics = False
.MatchAlefHamza = False
.MatchControl = False
.MatchByte = False
.CorrectHangulEndings = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchFuzzy = False
.MatchWildcards = True
End With

Selection.Find.Execute
Selection.ClearFormatting
Selection.ClearFormatting

Thanks

fumei
07-20-2009, 01:08 PM
Could you explain cstyle? What is this? Text?

Do you ONLY want to clear format for the Found item?

liverpool
07-21-2009, 04:54 AM
What i am searching for is all tags that start with <cf cstyle.

The below is the wild cards that i use to serach for the strat of the tag and any value up to the ">" charcter

.Text = "\<\cf cstyle?*\>"

As the file contains many of these tags, i would like to create a macro to search for all occurencs and when found clear the formatting.

Thanks

fumei
07-21-2009, 02:48 PM
You did not answer the question. All you did was repeat your original post.

.Text = "\<\cf cstyle?*\>"

Read that again. Text.

So it is going to look for....text. As in "cstyle"...TEXT.

That does not look for ANY style whatsoever. If you want to search for a Style, you use....

.Style =

macropod
07-21-2009, 05:11 PM
Hi liverpool,

Please see: http://www.excelguru.ca/node/7

I am not impressed at finding that, while I've been trying to help you solve the same problem at: http://www.techsupportforum.com/microsoft-support/microsoft-office-support/396669-macro-clear-formatting.html, you're asking others to traverse the same ground here. I'm sure fumei won't be impressed either.

Please, if you're going to pose the same question in multiple forums, at least have the courtesy of saying so.

fumei
07-22-2009, 01:19 PM
Indeed, I am not. However, liverpool, please read the link that macropod posted explaining WHY we want to know if someone is cross-posting.

There is nothing inherently wrong with "two forums are better than one".

But we want to know that because if you are being helped by macropod (who definitely knows what is what) someplace else, I am not going to waste my time duplicating things. THAT is the point of informing people when you cross-post. Again, please read the link macropod posted.

I must say though, after reading the other forum posting, you do not appear to be really listening all that well.