Re: Macro using a Loop by Ann
Ann
Thu Dec 04 17:25:42 CST 2003
Thanks, Ed. I will give it a try.
Ann
>-----Original Message-----
>Try a search for a paragraph mark and your
constant: "^pABC" and see if that
>works.
>
>Ed
>
>"Ann" <anonymous@discussions.microsoft.com> wrote in
message
>news:089601c3ba96$18d467e0$a001280a@phx.gbl...
>> Hi Ed,
>>
>> There is a three letter constant at the first of each
>> line, the only thing is that three letter combination
can
>> also be found in the clients name. If my constant
>> is "ABC" and do a loop using this text, it will also
pull
>> in the "ABC" combo if it is in the client name. Thus,
my
>> information will not be accurate. For Example:
>>
>> Constant Client name
>> ANN ANN ANYONE
>> ANN XYZ ANYONE
>>
>> The loop will pull the ANN from the constant and client
>> name. Do you have any suggestions on how to avoid
this?
>> Thanks in advance.
>>
>> Ann
>> >-----Original Message-----
>> >If I read your post correctly, the same word is in
each
>> line containing
>> >characters that need to be deleted. If so, then the
>> following code may work
>> >for you. Put your "target word" in the appropriate
>> place. I'm sure there
>> >are other ways of doing this, but I found that making
the
>> >Selection.Find.Execute part of the loop, and basing
>> actions on If .Found =
>> >True Then gave me the fewest errors.
>> >
>> >HTH
>> >Ed
>> >
>> > Selection.Find.ClearFormatting
>> >
>> > With Selection.Find
>> >
>> > .Text = "YOUR TEXT TO FIND HERE"
>> >
>> > .Replacement.Text = ""
>> >
>> > .Forward = True
>> >
>> > .Wrap = wdFindStop
>> >
>> > .Format = False
>> >
>> > .MatchCase = False
>> >
>> > .MatchWholeWord = False
>> >
>> > .MatchWildcards = False
>> >
>> > .MatchSoundsLike = False
>> >
>> > .MatchAllWordForms = False
>> >
>> > End With
>> >
>> >
>> >
>> >Do
>> >
>> > Selection.Find.Execute
>> >
>> >
>> >
>> > If Selection.Find.Found = True Then
>> >
>> > Selection.MoveLeft Unit:=wdCharacter, Count:=1
>> >
>> > Selection.MoveRight Unit:=wdCharacter, _
>> >
>> > Count:=18, Extend:=wdExtend
>> >
>> > Selection.Delete Unit:=wdCharacter, Count:=1
>> >
>> > Else
>> >
>> > Exit Do
>> >
>> > End If
>> >
>> >Loop
>> >
>> >
>> >
>> >"Ann" <anonymous@discussions.microsoft.com> wrote in
>> message
>> >news:025701c3ba8e$02562bf0$a101280a@phx.gbl...
>> >> Hi all! I am working on creating a macro to delete
>> >> information in a report. I have a header section
and
>> >> under that I have client information. I need to
delete
>> >> the first 18 characters of each line for
>> confindentiality
>> >> reasons. The number of clients varies per report,
so
>> >> there is not a constant number of lines. If I only
>> need
>> >> to delete one line, I could have the macro find a
>> certain
>> >> word in the report, go to the start of the line to
be
>> >> deleted, select the characters to be deleted, and
>> delete
>> >> that section, but I have multiple lines. I want to
do
>> a
>> >> loop, but I am not sure how I should do this. Does
>> >> anyone have any suggestions? Thanks in advance.
>> >>
>> >> Ann
>> >
>> >
>> >.
>> >
>
>
>.
>