Determine first text character in paragraph

J

jbc

Hello,

In certain instances, I need word to select and delete up to the first
"true" character of a paragraph. What I would need it to select and delete
are tabs and/or field codes.

Thanks
 
H

Helmut Weber

Hi,

what is a true character?

Example for "a" to "z" or "A" to "Z" or a field:

With Selection.Paragraphs(1).Range
While .Characters(1) Like "[A-Za-z]" = False Or _
.Characters(1).Fields.Count = 1
If .Characters(1).Fields.Count = 1 Then
.Characters(1).Fields(1).Delete
Else
.Characters(1).Delete
End If
Wend
End With

Or, if you want to delete fields and not printable characters
including space, then the condition would be:

While Asc(.Characters(1)) < 33 Or _
.Characters(1).Fields.Count = 1


--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 

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