Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / December 2005

Tip: Looking for answers? Try searching our database.

Determine first text character in paragraph

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jbc - 30 Dec 2005 02:57 GMT
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
Helmut Weber - 30 Dec 2005 10:35 GMT
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

Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

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

jbc - 30 Dec 2005 12:07 GMT
Thank you for all of your help Helmut.

> Hi,
>
[quoted text clipped - 18 lines]
>    While Asc(.Characters(1)) < 33 Or _
>       .Characters(1).Fields.Count = 1
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.