delete duplicate line on every page

M

mihai

Hi

I have documents where on every page a line is duplicated:
Bezeichnung: Audi C5 Ava. HSM DIN:
Bezeichnung: Audi C5 Ava. HSM DIN:
I want to delete the duplicate line.
I recorded a VB code that works for documents with two pages.
How can it be modified to work with more pages?
Thanks for any help.

Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = " Bezei*^13"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute
With Selection
If .Find.Forward = True Then
.Collapse Direction:=wdCollapseStart
Else
.Collapse Direction:=wdCollapseEnd
End If
.Find.Execute Replace:=wdReplaceOne
If .Find.Forward = True Then
.Collapse Direction:=wdCollapseEnd
Else
.Collapse Direction:=wdCollapseStart
End If
.Find.Execute
End With
Selection.Find.Execute
With Selection
If .Find.Forward = True Then
.Collapse Direction:=wdCollapseStart
Else
.Collapse Direction:=wdCollapseEnd
End If
.Find.Execute Replace:=wdReplaceOne
If .Find.Forward = True Then
.Collapse Direction:=wdCollapseEnd
Else
.Collapse Direction:=wdCollapseStart
End If
.Find.Execute
End With
Selection.Find.Execut
 
D

Doug Robbins - Word MVP - DELETE UPPERCASE CHARACT

Use:

Selection.HomeKey wdStory
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "(Bezei*^13)(Bezei*^13)"
.Replacement.Text = "\1"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll

See the article “Finding and replacing characters using wildcards” at:

http://word.mvps.org/FAQs/General/UsingWildcards.htm




--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.
Hope this helps
Doug Robbins - Word MVP
 
M

mihai

Your code works by it has generated a new problem. My code is:

'Ma intorc la inceputul documentului
Selection.HomeKey Unit:=wdStory
'Setez sourec si definesc selectia
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(findtext:="&k2S*&k0S", MatchWildcards:=True, _
Wrap:=wdFindContinue, Forward:=False) = True
'copiez selectia
Set arange = Selection.Range

......... a lot of code

'elimin linia dubla cu bezeichnung
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "( Bezei*^13)( Bezei*^13)"
.Replacement.Text = "\1"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
Target.Close
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
Loop
End With

The first loop works fin but then Word gives the following erro
'5623':
"The Replace With text contains a group number which is out of range."
Why is this
 

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