Automate this macro please.


G

Guest

Hello from Steved

The below macro is designed to run manually meaning to do a whole document i
push the macro button each time, is there something that can be added or
changed
to do the whole document please. I mean push the macro button and it
completes the total Document.

Sub LeftMargin()
Selection.Find.ClearFormatting
With Selection.Find
.Text = "^$:"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.HomeKey Unit:=wdLine
Selection.Extend
Selection.Find.ClearFormatting
With Selection.Find
.Text = "^$:"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=8
Selection.TypeText Text:=" "
End Sub


Thankyou.
 
Ad

Advertisements

G

Graham Mayor

What is the nature of the document and what is it that you are trying to do
with this macro?
Incidentally macro questions are best posted to one of the Word vba groups.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
G

Guest

Hello Graham from Steved

I've 2 lines off information

The 1st line contains 1st: 2nd: all the way to 24th.

Thats is what is been deleted ( 1st: 2nd: all the way to 24th.)

The second line needs the delete button to be pushed 8 times to line up with
the line above. ( the line Ive just done the deleting )

Thankyou.
 
G

Graham Mayor

Something seems to have got lost in the translation as I am even more
confused now than before. Can you paste a sample of the text into your
message and let us know what you want to do with that text. Forget the macro
for now. What exactly are you trying to do?

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
G

Guest

Hello from Steved

Looking at below if I delete 8th: the line below will need to be bought
back into line as show'n in the 2 examples below.

From This
8th: 1 PRIMARY 726269X42 ( 3) 57.0 S COLLINS 49.8 4 H

EEFFEE FG T( 8 0 3) F( 4 0 2) C( 1 0
0)
To this
1 PRIMARY 726269X42 ( 3) 57.0 S COLLINS 49.8 4 H
EEFFEE FG T( 8 0 3) F( 4 0 2) C( 1 0 0)

Thankyou.
 
G

Graham Mayor

This appears to be a relatively straightforward wildcard search and replace
of
[0-9]{1,}[dhstr]{2}:[ ]@
with nothing. - http://www.gmayor.com/replace_using_wildcards.htm

Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "[0-9]{1,}[dhstr]{2}:[ ]@"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute replace:=wdReplaceAll


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
Ad

Advertisements

G

Guest

Thankyou.

Graham Mayor said:
This appears to be a relatively straightforward wildcard search and replace
of
[0-9]{1,}[dhstr]{2}:[ ]@
with nothing. - http://www.gmayor.com/replace_using_wildcards.htm

Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "[0-9]{1,}[dhstr]{2}:[ ]@"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute replace:=wdReplaceAll


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

Hello from Steved

Looking at below if I delete 8th: the line below will need to be
bought back into line as show'n in the 2 examples below.

From This
8th: 1 PRIMARY 726269X42 ( 3) 57.0 S COLLINS 49.8 4 H

EEFFEE FG T( 8 0 3) F( 4 0 2)
C( 1 0 0)
To this
1 PRIMARY 726269X42 ( 3) 57.0 S COLLINS 49.8 4 H
EEFFEE FG T( 8 0 3) F( 4 0 2) C( 1 0 0)

Thankyou.
 

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