Group:  Microsoft Word ยป microsoft.public.word.vba.customization
Thread: Macro help needed please

Geek News

Macro help needed please
"Alan B. Densky" <sales[ at ]neuro-vision.us> 4/20/2007 7:33:13 PM
Hello,

I'm using Word 2000.

I am trying to write a macro that will delete a specifi parts of a document.

A static text string that never changes is in the document and it marks the
BEGINNING of the block that I want to select and delete.

A static text string that never changes is in the document and it marks the
END of the block that I want to select and delete.

The amount of text between the starting point and the ending point (that I
want to delete) varies with each document.

I need to be able to somehow use the Edit | Find to find that ending string
and then select all of the text between the starting point and the ending
point.

Does anyone know how to do this? If so, could you please write a macro and
post it? I'm sure that I could take your code and insert it into the macro
editor and make the other changes that I need.

Thank you,

Alan


Re: Macro help needed please
Jay Freedman <jay.freedman[ at ]verizon.net> 4/21/2007 2:47:09 AM
A macro isn't really necessary, unless you need to do the same thing
repeatedly. All you need is a wildcard replace. The theory and
background are at http://www.gmayor.com/replace_using_wildcards.htm.

Since you didn't reveal the magic text of the start and stop markers,
I'll simulate them with "StartText" and "StopText".

- Open the Replace dialog, click the More button, and check the "Use
wildcards" box.

- In the Find What box, enter

(StartText)(*)(StopText)

- In the Replace With box, if you want to keep the StartText and
StopText markers, enter the code

\1\3

If you want the whole thing to disappear including the markers, leave
the Replace With box empty.

- Click the Replace All button.

As a macro, the procedure should be coded like this:

Sub demo()
Dim oRg As Range
Set oRg = ActiveDocument.Range
With oRg.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "(StartText)(*)(StopText)"
.Replacement.Text = "\1\3"
.Format = False
.MatchWildcards = True
.Wrap = wdFindContinue
.Execute Replace:=wdReplaceAll
End With
End Sub

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Fri, 20 Apr 2007 15:33:13 -0400, "Alan B. Densky"
<sales[ at ]neuro-vision.us> wrote:

[Quoted Text]
>Hello,
>
>I'm using Word 2000.
>
>I am trying to write a macro that will delete a specifi parts of a document.
>
>A static text string that never changes is in the document and it marks the
>BEGINNING of the block that I want to select and delete.
>
>A static text string that never changes is in the document and it marks the
>END of the block that I want to select and delete.
>
>The amount of text between the starting point and the ending point (that I
>want to delete) varies with each document.
>
>I need to be able to somehow use the Edit | Find to find that ending string
>and then select all of the text between the starting point and the ending
>point.
>
>Does anyone know how to do this? If so, could you please write a macro and
>post it? I'm sure that I could take your code and insert it into the macro
>editor and make the other changes that I need.
>
>Thank you,
>
>Alan
>
Re: Macro help needed please
"Alan B. Densky" <sales[ at ]neuro-vision.us> 4/22/2007 12:52:22 AM
Hi Jay,

Thanks for your help. I do need to do it in a macro. I'll tell you exactly
what I'm doing, and then you'll understand.

I write articles that I submit to article directories to market my website.
The submission rules for every article directory are different, but they
basically fall into two groups:

1. Directories that allow you to have links in your article's body
2. Directories that DO NOT allow you to have links in your article's body

I write the article without links, and then write a block of text (a couple
of paragraphs) that does have links. I mark the start and the end of the
block that doesn't have links, and I mark the start and the end of the block
that does have links.

My articles are spun, that is - each article is setup into a seed article
format that has hundreds of synonomous words and phrases. The article
spinning software spins out hundreds of variations of the article into one
long document. Each version of the article is a minimum of 30% different
from every other version. No mind you, they all say the same thing, but they
use different words.

Since each version of the article is different, each block (either with or
without the links) varies in length. So I need to be able to search for the
beginning and the ending of each block that is to be deleted. Merely
counting lines with a down arrow is not nearly accurate enough.

This allows me to submit a different and unique version of each article to
every article directory. This is to escape the Google duplicate content
filters.

Now, as I visit each article directory, I advance to the next version of the
article in the document, and I run the appropriate macro which finds either
the block of text that has links, or the block of text that doesn't have
links, and it deletes the appropriate block to prep the article based on the
requirements of the specific article directory.

This happens hundreds of times. Manually finding and deleting each of these
blocks of text is tedius and very time consuming.

So hopefully now that you understand why I need to be able to find certain
blocks and select them for deletion, you will give me the info that I
requested.

As far as using the find dialog, or using it and recording it in a macro,
I've been doing that for many, many years.

Thanks,
Alan





"Jay Freedman" <jay.freedman[ at ]verizon.net> wrote in message
news:l4ui231s1e7fjvqvtptahaett8ehg2q4ji[ at ]4ax.com...
[Quoted Text]
> A macro isn't really necessary, unless you need to do the same thing
> repeatedly. All you need is a wildcard replace. The theory and
> background are at http://www.gmayor.com/replace_using_wildcards.htm.
>
> Since you didn't reveal the magic text of the start and stop markers,
> I'll simulate them with "StartText" and "StopText".
>
> - Open the Replace dialog, click the More button, and check the "Use
> wildcards" box.
>
> - In the Find What box, enter
>
> (StartText)(*)(StopText)
>
> - In the Replace With box, if you want to keep the StartText and
> StopText markers, enter the code
>
> \1\3
>
> If you want the whole thing to disappear including the markers, leave
> the Replace With box empty.
>
> - Click the Replace All button.
>
> As a macro, the procedure should be coded like this:
>
> Sub demo()
> Dim oRg As Range
> Set oRg = ActiveDocument.Range
> With oRg.Find
> .ClearFormatting
> .Replacement.ClearFormatting
> .Text = "(StartText)(*)(StopText)"
> .Replacement.Text = "\1\3"
> .Format = False
> .MatchWildcards = True
> .Wrap = wdFindContinue
> .Execute Replace:=wdReplaceAll
> End With
> End Sub
>
> --
> Regards,
> Jay Freedman
> Microsoft Word MVP FAQ: http://word.mvps.org
> Email cannot be acknowledged; please post all follow-ups to the
> newsgroup so all may benefit.
>
> On Fri, 20 Apr 2007 15:33:13 -0400, "Alan B. Densky"
> <sales[ at ]neuro-vision.us> wrote:
>
> >Hello,
> >
> >I'm using Word 2000.
> >
> >I am trying to write a macro that will delete a specifi parts of a
document.
> >
> >A static text string that never changes is in the document and it marks
the
> >BEGINNING of the block that I want to select and delete.
> >
> >A static text string that never changes is in the document and it marks
the
> >END of the block that I want to select and delete.
> >
> >The amount of text between the starting point and the ending point (that
I
> >want to delete) varies with each document.
> >
> >I need to be able to somehow use the Edit | Find to find that ending
string
> >and then select all of the text between the starting point and the ending
> >point.
> >
> >Does anyone know how to do this? If so, could you please write a macro
and
> >post it? I'm sure that I could take your code and insert it into the
macro
> >editor and make the other changes that I need.
> >
> >Thank you,
> >
> >Alan
> >


Re: Macro help needed please
Jay Freedman <jay.freedman[ at ]verizon.net> 4/22/2007 3:11:13 AM
Hi Alan,

I already gave you the macro code. You just have to put in the actual
markers for the start and end of the block, instead of the "StartText"
and "StopText" that I inserted as placeholders.

If that isn't what you want, please let me know what part of its
behavior should be changed.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Sat, 21 Apr 2007 20:52:22 -0400, "Alan B. Densky"
<sales[ at ]neuro-vision.us> wrote:

[Quoted Text]
>Hi Jay,
>
>Thanks for your help. I do need to do it in a macro. I'll tell you exactly
>what I'm doing, and then you'll understand.
>
>I write articles that I submit to article directories to market my website.
>The submission rules for every article directory are different, but they
>basically fall into two groups:
>
>1. Directories that allow you to have links in your article's body
>2. Directories that DO NOT allow you to have links in your article's body
>
>I write the article without links, and then write a block of text (a couple
>of paragraphs) that does have links. I mark the start and the end of the
>block that doesn't have links, and I mark the start and the end of the block
>that does have links.
>
>My articles are spun, that is - each article is setup into a seed article
>format that has hundreds of synonomous words and phrases. The article
>spinning software spins out hundreds of variations of the article into one
>long document. Each version of the article is a minimum of 30% different
>from every other version. No mind you, they all say the same thing, but they
>use different words.
>
>Since each version of the article is different, each block (either with or
>without the links) varies in length. So I need to be able to search for the
>beginning and the ending of each block that is to be deleted. Merely
>counting lines with a down arrow is not nearly accurate enough.
>
>This allows me to submit a different and unique version of each article to
>every article directory. This is to escape the Google duplicate content
>filters.
>
>Now, as I visit each article directory, I advance to the next version of the
>article in the document, and I run the appropriate macro which finds either
>the block of text that has links, or the block of text that doesn't have
>links, and it deletes the appropriate block to prep the article based on the
>requirements of the specific article directory.
>
>This happens hundreds of times. Manually finding and deleting each of these
>blocks of text is tedius and very time consuming.
>
>So hopefully now that you understand why I need to be able to find certain
>blocks and select them for deletion, you will give me the info that I
>requested.
>
>As far as using the find dialog, or using it and recording it in a macro,
>I've been doing that for many, many years.
>
>Thanks,
>Alan
>
>
>
>
>
>"Jay Freedman" <jay.freedman[ at ]verizon.net> wrote in message
>news:l4ui231s1e7fjvqvtptahaett8ehg2q4ji[ at ]4ax.com...
>> A macro isn't really necessary, unless you need to do the same thing
>> repeatedly. All you need is a wildcard replace. The theory and
>> background are at http://www.gmayor.com/replace_using_wildcards.htm.
>>
>> Since you didn't reveal the magic text of the start and stop markers,
>> I'll simulate them with "StartText" and "StopText".
>>
>> - Open the Replace dialog, click the More button, and check the "Use
>> wildcards" box.
>>
>> - In the Find What box, enter
>>
>> (StartText)(*)(StopText)
>>
>> - In the Replace With box, if you want to keep the StartText and
>> StopText markers, enter the code
>>
>> \1\3
>>
>> If you want the whole thing to disappear including the markers, leave
>> the Replace With box empty.
>>
>> - Click the Replace All button.
>>
>> As a macro, the procedure should be coded like this:
>>
>> Sub demo()
>> Dim oRg As Range
>> Set oRg = ActiveDocument.Range
>> With oRg.Find
>> .ClearFormatting
>> .Replacement.ClearFormatting
>> .Text = "(StartText)(*)(StopText)"
>> .Replacement.Text = "\1\3"
>> .Format = False
>> .MatchWildcards = True
>> .Wrap = wdFindContinue
>> .Execute Replace:=wdReplaceAll
>> End With
>> End Sub
>>
>> --
>> Regards,
>> Jay Freedman
>> Microsoft Word MVP FAQ: http://word.mvps.org
>> Email cannot be acknowledged; please post all follow-ups to the
>> newsgroup so all may benefit.
>>
>> On Fri, 20 Apr 2007 15:33:13 -0400, "Alan B. Densky"
>> <sales[ at ]neuro-vision.us> wrote:
>>
>> >Hello,
>> >
>> >I'm using Word 2000.
>> >
>> >I am trying to write a macro that will delete a specifi parts of a
>document.
>> >
>> >A static text string that never changes is in the document and it marks
>the
>> >BEGINNING of the block that I want to select and delete.
>> >
>> >A static text string that never changes is in the document and it marks
>the
>> >END of the block that I want to select and delete.
>> >
>> >The amount of text between the starting point and the ending point (that
>I
>> >want to delete) varies with each document.
>> >
>> >I need to be able to somehow use the Edit | Find to find that ending
>string
>> >and then select all of the text between the starting point and the ending
>> >point.
>> >
>> >Does anyone know how to do this? If so, could you please write a macro
>and
>> >post it? I'm sure that I could take your code and insert it into the
>macro
>> >editor and make the other changes that I need.
>> >
>> >Thank you,
>> >
>> >Alan
>> >
>
Re: Macro help needed please
"Alan B. Densky" <sales[ at ]neuro-vision.us> 4/23/2007 10:17:28 PM
Hi Jay,

Thanks for your help. This is pretty close. I just need to know what I can
replace the .Execute Replace:=wdReplaceAll
with so that it doesn't delete every instance in the document, just the
first one it comes to. I tried wdReplace, but it didn't like that.

Alan


"Jay Freedman" <jay.freedman[ at ]verizon.net> wrote in message
news:vdkl23dahr2nkafc8e4c49c22lk5sd9l98[ at ]4ax.com...
[Quoted Text]
> Hi Alan,
>
> I already gave you the macro code. You just have to put in the actual
> markers for the start and end of the block, instead of the "StartText"
> and "StopText" that I inserted as placeholders.
>
> If that isn't what you want, please let me know what part of its
> behavior should be changed.
>
> --
> Regards,
> Jay Freedman
> Microsoft Word MVP FAQ: http://word.mvps.org
> Email cannot be acknowledged; please post all follow-ups to the
> newsgroup so all may benefit.
>
> On Sat, 21 Apr 2007 20:52:22 -0400, "Alan B. Densky"
> <sales[ at ]neuro-vision.us> wrote:
>
> >Hi Jay,
> >
> >Thanks for your help. I do need to do it in a macro. I'll tell you
exactly
> >what I'm doing, and then you'll understand.
> >
> >I write articles that I submit to article directories to market my
website.
> >The submission rules for every article directory are different, but they
> >basically fall into two groups:
> >
> >1. Directories that allow you to have links in your article's body
> >2. Directories that DO NOT allow you to have links in your article's body
> >
> >I write the article without links, and then write a block of text (a
couple
> >of paragraphs) that does have links. I mark the start and the end of the
> >block that doesn't have links, and I mark the start and the end of the
block
> >that does have links.
> >
> >My articles are spun, that is - each article is setup into a seed article
> >format that has hundreds of synonomous words and phrases. The article
> >spinning software spins out hundreds of variations of the article into
one
> >long document. Each version of the article is a minimum of 30% different
> >from every other version. No mind you, they all say the same thing, but
they
> >use different words.
> >
> >Since each version of the article is different, each block (either with
or
> >without the links) varies in length. So I need to be able to search for
the
> >beginning and the ending of each block that is to be deleted. Merely
> >counting lines with a down arrow is not nearly accurate enough.
> >
> >This allows me to submit a different and unique version of each article
to
> >every article directory. This is to escape the Google duplicate content
> >filters.
> >
> >Now, as I visit each article directory, I advance to the next version of
the
> >article in the document, and I run the appropriate macro which finds
either
> >the block of text that has links, or the block of text that doesn't have
> >links, and it deletes the appropriate block to prep the article based on
the
> >requirements of the specific article directory.
> >
> >This happens hundreds of times. Manually finding and deleting each of
these
> >blocks of text is tedius and very time consuming.
> >
> >So hopefully now that you understand why I need to be able to find
certain
> >blocks and select them for deletion, you will give me the info that I
> >requested.
> >
> >As far as using the find dialog, or using it and recording it in a macro,
> >I've been doing that for many, many years.
> >
> >Thanks,
> >Alan
> >
> >
> >
> >
> >
> >"Jay Freedman" <jay.freedman[ at ]verizon.net> wrote in message
> >news:l4ui231s1e7fjvqvtptahaett8ehg2q4ji[ at ]4ax.com...
> >> A macro isn't really necessary, unless you need to do the same thing
> >> repeatedly. All you need is a wildcard replace. The theory and
> >> background are at http://www.gmayor.com/replace_using_wildcards.htm.
> >>
> >> Since you didn't reveal the magic text of the start and stop markers,
> >> I'll simulate them with "StartText" and "StopText".
> >>
> >> - Open the Replace dialog, click the More button, and check the "Use
> >> wildcards" box.
> >>
> >> - In the Find What box, enter
> >>
> >> (StartText)(*)(StopText)
> >>
> >> - In the Replace With box, if you want to keep the StartText and
> >> StopText markers, enter the code
> >>
> >> \1\3
> >>
> >> If you want the whole thing to disappear including the markers, leave
> >> the Replace With box empty.
> >>
> >> - Click the Replace All button.
> >>
> >> As a macro, the procedure should be coded like this:
> >>
> >> Sub demo()
> >> Dim oRg As Range
> >> Set oRg = ActiveDocument.Range
> >> With oRg.Find
> >> .ClearFormatting
> >> .Replacement.ClearFormatting
> >> .Text = "(StartText)(*)(StopText)"
> >> .Replacement.Text = "\1\3"
> >> .Format = False
> >> .MatchWildcards = True
> >> .Wrap = wdFindContinue
> >> .Execute Replace:=wdReplaceAll
> >> End With
> >> End Sub
> >>
> >> --
> >> Regards,
> >> Jay Freedman
> >> Microsoft Word MVP FAQ: http://word.mvps.org
> >> Email cannot be acknowledged; please post all follow-ups to the
> >> newsgroup so all may benefit.
> >>
> >> On Fri, 20 Apr 2007 15:33:13 -0400, "Alan B. Densky"
> >> <sales[ at ]neuro-vision.us> wrote:
> >>
> >> >Hello,
> >> >
> >> >I'm using Word 2000.
> >> >
> >> >I am trying to write a macro that will delete a specifi parts of a
> >document.
> >> >
> >> >A static text string that never changes is in the document and it
marks
> >the
> >> >BEGINNING of the block that I want to select and delete.
> >> >
> >> >A static text string that never changes is in the document and it
marks
> >the
> >> >END of the block that I want to select and delete.
> >> >
> >> >The amount of text between the starting point and the ending point
(that
> >I
> >> >want to delete) varies with each document.
> >> >
> >> >I need to be able to somehow use the Edit | Find to find that ending
> >string
> >> >and then select all of the text between the starting point and the
ending
> >> >point.
> >> >
> >> >Does anyone know how to do this? If so, could you please write a macro
> >and
> >> >post it? I'm sure that I could take your code and insert it into the
> >macro
> >> >editor and make the other changes that I need.
> >> >
> >> >Thank you,
> >> >
> >> >Alan
> >> >
> >


Re: Macro help needed please
"Alan B. Densky" <AlanD[ at ]neuro-vision.us> 4/24/2007 5:26:53 AM
Hi Jay,

Forget the previous post. I've just about got everything working now. I
have one section of the macro left to do.

After I do the find & replace, I need to select a range of text. I have to
go back up to the top of the article (this is not the top of the document
because there is a string of hundreds of versions of the article in this
very long document.

Then I need to select a range of text (moving down in the document).

It would also be nice if I could copy that range to the clipboard.

Here is what I have so far:
Sub LeaveLinks()
'
' LeaveLinks Macro
' Macro recorded 4/18/2007
'
'Find the string that starts the links block of text and delete the text on
that line
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "LINKS SECTION======"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
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

'Delete the block of text that doesn't have any links in it
Dim oRg As Range
Set oRg = ActiveDocument.Range
With oRg.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "(NO LINKS SECTION======)(*)(END NO LINKS SECTION======)"
.Replacement.Text = ""
.Forward = True
.Format = False
.MatchWildcards = True
.Wrap = wdFindContinue
.Execute Replace:=Word.WdReplace.wdReplaceOne
End With

'Go back up and find the beginning of the article

Selection.Find.ClearFormatting
With Selection.Find
.Text = "Article With Back links"
.Replacement.Text = ""
.Forward = False
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute

'Select the range of text to copy to the clipboard
With oRg.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "(Article With Back links)(*)(END NO LINKS SECTION======2)"
' ' .Replacement.Text = ""
.Forward = True
.Format = False
.MatchWildcards = True
.Wrap = wdFindContinue
.Execute Replace:=Word.WdReplace.wdReplaceOne
End With

'Copy the selected range to the clipboard

End Sub



Thanks for all of your help!

Alan


"Alan B. Densky" <sales[ at ]neuro-vision.us> wrote in message
news:MeaXh.33790$254.17869[ at ]bignews7.bellsouth.net...
[Quoted Text]
> Hi Jay,
>
> Thanks for your help. This is pretty close. I just need to know what I can
> replace the .Execute Replace:=wdReplaceAll
> with so that it doesn't delete every instance in the document, just the
> first one it comes to. I tried wdReplace, but it didn't like that.
>
> Alan
>
>
> "Jay Freedman" <jay.freedman[ at ]verizon.net> wrote in message
> news:vdkl23dahr2nkafc8e4c49c22lk5sd9l98[ at ]4ax.com...
>> Hi Alan,
>>
>> I already gave you the macro code. You just have to put in the actual
>> markers for the start and end of the block, instead of the "StartText"
>> and "StopText" that I inserted as placeholders.
>>
>> If that isn't what you want, please let me know what part of its
>> behavior should be changed.
>>
>> --
>> Regards,
>> Jay Freedman
>> Microsoft Word MVP FAQ: http://word.mvps.org
>> Email cannot be acknowledged; please post all follow-ups to the
>> newsgroup so all may benefit.
>>
>> On Sat, 21 Apr 2007 20:52:22 -0400, "Alan B. Densky"
>> <sales[ at ]neuro-vision.us> wrote:
>>
>> >Hi Jay,
>> >
>> >Thanks for your help. I do need to do it in a macro. I'll tell you
> exactly
>> >what I'm doing, and then you'll understand.
>> >
>> >I write articles that I submit to article directories to market my
> website.
>> >The submission rules for every article directory are different, but they
>> >basically fall into two groups:
>> >
>> >1. Directories that allow you to have links in your article's body
>> >2. Directories that DO NOT allow you to have links in your article's
>> >body
>> >
>> >I write the article without links, and then write a block of text (a
> couple
>> >of paragraphs) that does have links. I mark the start and the end of the
>> >block that doesn't have links, and I mark the start and the end of the
> block
>> >that does have links.
>> >
>> >My articles are spun, that is - each article is setup into a seed
>> >article
>> >format that has hundreds of synonomous words and phrases. The article
>> >spinning software spins out hundreds of variations of the article into
> one
>> >long document. Each version of the article is a minimum of 30% different
>> >from every other version. No mind you, they all say the same thing, but
> they
>> >use different words.
>> >
>> >Since each version of the article is different, each block (either with
> or
>> >without the links) varies in length. So I need to be able to search for
> the
>> >beginning and the ending of each block that is to be deleted. Merely
>> >counting lines with a down arrow is not nearly accurate enough.
>> >
>> >This allows me to submit a different and unique version of each article
> to
>> >every article directory. This is to escape the Google duplicate content
>> >filters.
>> >
>> >Now, as I visit each article directory, I advance to the next version of
> the
>> >article in the document, and I run the appropriate macro which finds
> either
>> >the block of text that has links, or the block of text that doesn't have
>> >links, and it deletes the appropriate block to prep the article based on
> the
>> >requirements of the specific article directory.
>> >
>> >This happens hundreds of times. Manually finding and deleting each of
> these
>> >blocks of text is tedius and very time consuming.
>> >
>> >So hopefully now that you understand why I need to be able to find
> certain
>> >blocks and select them for deletion, you will give me the info that I
>> >requested.
>> >
>> >As far as using the find dialog, or using it and recording it in a
>> >macro,
>> >I've been doing that for many, many years.
>> >
>> >Thanks,
>> >Alan
>> >
>> >
>> >
>> >
>> >
>> >"Jay Freedman" <jay.freedman[ at ]verizon.net> wrote in message
>> >news:l4ui231s1e7fjvqvtptahaett8ehg2q4ji[ at ]4ax.com...
>> >> A macro isn't really necessary, unless you need to do the same thing
>> >> repeatedly. All you need is a wildcard replace. The theory and
>> >> background are at http://www.gmayor.com/replace_using_wildcards.htm.
>> >>
>> >> Since you didn't reveal the magic text of the start and stop markers,
>> >> I'll simulate them with "StartText" and "StopText".
>> >>
>> >> - Open the Replace dialog, click the More button, and check the "Use
>> >> wildcards" box.
>> >>
>> >> - In the Find What box, enter
>> >>
>> >> (StartText)(*)(StopText)
>> >>
>> >> - In the Replace With box, if you want to keep the StartText and
>> >> StopText markers, enter the code
>> >>
>> >> \1\3
>> >>
>> >> If you want the whole thing to disappear including the markers, leave
>> >> the Replace With box empty.
>> >>
>> >> - Click the Replace All button.
>> >>
>> >> As a macro, the procedure should be coded like this:
>> >>
>> >> Sub demo()
>> >> Dim oRg As Range
>> >> Set oRg = ActiveDocument.Range
>> >> With oRg.Find
>> >> .ClearFormatting
>> >> .Replacement.ClearFormatting
>> >> .Text = "(StartText)(*)(StopText)"
>> >> .Replacement.Text = "\1\3"
>> >> .Format = False
>> >> .MatchWildcards = True
>> >> .Wrap = wdFindContinue
>> >> .Execute Replace:=wdReplaceAll
>> >> End With
>> >> End Sub
>> >>
>> >> --
>> >> Regards,
>> >> Jay Freedman
>> >> Microsoft Word MVP FAQ: http://word.mvps.org
>> >> Email cannot be acknowledged; please post all follow-ups to the
>> >> newsgroup so all may benefit.
>> >>
>> >> On Fri, 20 Apr 2007 15:33:13 -0400, "Alan B. Densky"
>> >> <sales[ at ]neuro-vision.us> wrote:
>> >>
>> >> >Hello,
>> >> >
>> >> >I'm using Word 2000.
>> >> >
>> >> >I am trying to write a macro that will delete a specifi parts of a
>> >document.
>> >> >
>> >> >A static text string that never changes is in the document and it
> marks
>> >the
>> >> >BEGINNING of the block that I want to select and delete.
>> >> >
>> >> >A static text string that never changes is in the document and it
> marks
>> >the
>> >> >END of the block that I want to select and delete.
>> >> >
>> >> >The amount of text between the starting point and the ending point
> (that
>> >I
>> >> >want to delete) varies with each document.
>> >> >
>> >> >I need to be able to somehow use the Edit | Find to find that ending
>> >string
>> >> >and then select all of the text between the starting point and the
> ending
>> >> >point.
>> >> >
>> >> >Does anyone know how to do this? If so, could you please write a
>> >> >macro
>> >and
>> >> >post it? I'm sure that I could take your code and insert it into the
>> >macro
>> >> >editor and make the other changes that I need.
>> >> >
>> >> >Thank you,
>> >> >
>> >> >Alan
>> >> >
>> >
>
>


Re: Macro help needed please
<omeolad1[ at ]vic.chariot.net.au> 5/23/2007 1:24:18 PM

"Alan B. Densky" <sales[ at ]neuro-vision.us> wrote in message
news:Oy8Wh.926$TD3.238[ at ]bignews5.bellsouth.net...
[Quoted Text]
> Hello,
>
> I'm using Word 2000.
>
> I am trying to write a macro that will delete a specifi parts of a
> document.
>
> A static text string that never changes is in the document and it marks
> the
> BEGINNING of the block that I want to select and delete.
>
> A static text string that never changes is in the document and it marks
> the
> END of the block that I want to select and delete.
>
> The amount of text between the starting point and the ending point (that I
> want to delete) varies with each document.
>
> I need to be able to somehow use the Edit | Find to find that ending
> string
> and then select all of the text between the starting point and the ending
> point.
>
> Does anyone know how to do this? If so, could you please write a macro and
> post it? I'm sure that I could take your code and insert it into the macro
> editor and make the other changes that I need.
>
> Thank you,
>
> Alan
>
Hi if you just like macros for web base chat or games online
a cheats way of doing macros is use a little program called
shortkeys lite , it is free , cheers
>

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net