Deleting chars from a paragraph

N

Niek

We strip a document containing mergefields into a fixed part(image) and a variable part, for the use in a composing tool.
To do this we determine the paragraphs with mergefields and delete all characters, excl. the paragraphsign and manually inserted line-end(CTRL+Enter).

For Each aWord In par.Range.Characters
If Asc(aWord) <> 13 And Asc(aWord) <> 11 Then
aWord.Select
Selection.Delete
End If
Next

Under NT/Office97 and XP/XP this worked OK. But since XP/2003 it doesn't. All characters are deleted including manually inserted line-end(CTRL+Enter).
If you delete the characters manually and leaves the manually inserted line-end it also acts wrong????

Does anyone can explain this to me and help me with a solution.

Thanx.
 
D

Dave Lett

Hi Niek

I can't explain it, but I'd suggest that you do a search and replace for the characters you want to replace. It will work a _lot_ faster. You might use the following as a starting point on how to do thi

With Selection.Fin
.ClearFormattin
.Text = "[!^13^m]" '''everything _except_ paragraph sign and page/section break
.MatchWildcards = Tru
With .Replacemen
.Text = "
.ClearFormattin
End Wit
.Execute Replace:=wdReplaceAl
End Wit

HTH
Dave
 
N

Niek

Thanx Dave,

With the change from ^m into ^l it works perfect and indeed a lot faster.

Have a nice Xmas and a happy and healthy 2004.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top