AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
I saw a number of solutions here are what worked for me. If rng.Text = " " Or rng.Text = Chr(9) Then (Since this does not change the entire paragraph a "normal" loop works.) Sub TestTrimParas() If present, extend the range until no more of these characters are detected, and delete. String processing does not retain formatting.Īn alternative would be to check the first character of each paragraph for the kinds of characters you consider to be "white space". That said, if the paragraphs in the document contain any formatting this will be lost. The way to work around it is to loop the collection from the end to the front: For i = To 1 Step -1 This is normal behavior with objects that are getting deleted and recreated "behind the scenes". So the code will continually process the same paragraph at some point. The reason the code in the question is looping is because replacing one paragraph with the processed (trimmed) text is changing the paragraphs collection.
0 Comments
Read More
Leave a Reply. |