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 / July 2005

Tip: Looking for answers? Try searching our database.

Clear text between specified characters

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Tomislav - 22 Jun 2005 19:25 GMT
Hello,

i am new to Visual Basic and I am trying to make some macros for automated
dictionary reversing. What I must do is find all ranges between characters
"=" and "\" , and then clear them including ending sign "\". I tried few
methods and it always turns out wrong.

Can anyone help ?

Thanks

Tom
Anne Troy - 22 Jun 2005 22:23 GMT
Hi, Tom. There's an EXT in the status bar in Word. See it? That EXTENDS your
selection. So I would do a Find on "=" and then hit the right arrow key
once. Hit the EXT, and then do a Find for "\", and then hit Shift+Left
arrow. That should select if you're recording. How to loop? I dunno! :)
*******************
~Anne Troy

www.OfficeArticles.com
www.MyExpertsOnline.com

> Hello,
>
[quoted text clipped - 8 lines]
>
> Tom
Helmut Weber - 23 Jun 2005 13:15 GMT
Hi Tomislav,

not quite clear if you want to remove the "=", too.

If so:

Sub Test9082()
Dim rDcm As Range
Set rDcm = ActiveDocument.Range
ResetSearch
With rDcm.Find
  .Text = "=*\\" ' quoted backslash
  .Replacement.Text = ""
  .MatchWildcards = True
  .Execute Replace:=wdReplaceAll
End With
ResetSearch
End Sub

Public Sub ResetSearch()
With Selection.Find
  .ClearFormatting
  .Replacement.ClearFormatting
  .Text = ""
  .Replacement.Text = ""
  .Forward = True
  .Wrap = wdFindContinue
  .Format = False
  .MatchCase = False
  .MatchWholeWord = False
  .MatchWildcards = False
  .MatchSoundsLike = False
  .MatchAllWordForms = False
  .Execute
End With
End Sub

If not, then replace what you have found by "=".

Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000
Russs - 25 Jul 2005 00:33 GMT
I just read this message thread and my response might be too late, but I
thought others might be able to benefit from what I am writing below.

>>On 6/22/05 2:25 PM, in article d9caev$qqp$1@sunce.iskon.hr, "Tomislav"
>><optophone@mail.inet.hr> wrote:
[quoted text clipped - 18 lines]
> With rDcm.Find
>    .Text = "=*\\" ' quoted backslash
Sometimes the wildcard * can be too 'greedy' by crossing more than one line
to pair up the characters preceding and following the asterisk.

"The computer will do what I ask it to, not necessarily what I want it to
do!"

Something like:

    .Text = "=[!=\n]@\\"

might be more appropriate if you don't want to select more than one line.

The [!=\n]@ wildcard combination replacing the * means: one or more
characters as long they are not another '=' character or a '\n' (new line)
character. That will help 'restrict' what is selected as the computer is
searching for the next backslash to pair up with the last closest equals
sign and have both on the same line.
>    .Replacement.Text = ""
>    .MatchWildcards = True
[quoted text clipped - 27 lines]
> "red.sys" & chr(64) & "t-online.de"
> Word 2002, Windows 2000
Signature

Russs

drsmN0SPAMikleAThotmailD0Tcom.INVALID <-- fix this before replying

 
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.