Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

deleting text in doc with VBA

Status
Not open for further replies.

jeph

Programmer
Jun 21, 2000
10
DE
hi,
I don't have much experience in using VBA with Winword 2k, but i need to write a macro to find some text in a document and delete it.
the text looks like this { XE <index-name> }.

can somebody give me a hint how to start?

thanks,
jeph
 
Sub delete_text()
Dim del_text As String

del_text = InputBox(&quot;Enter the text to delete&quot;, &quot;My_Text_Deleter&quot;)
If del_text = &quot;&quot; Then Exit Sub

Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = del_text
.Replacement.Text = &quot;&quot;
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
 
the macro works, thanks.

I'm only having problems with the replacement text: { XE <something>}

I get an error message if i want to look for &quot;{ XE*}&quot; or &quot;^0123 XE*^0125&quot;.

 
the problem is that this is no ordinary text. the { XE ...} are bookmarks which need to be removed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top