Re: macro to select text from one point to another

Tech-Archive recommends: Fix windows errors by optimizing your registry



Greg,

Thanks loads.

It does what exactly what I need. (Now to figure out exactly what it is
doing, so I can modify it if necessary.)

One thing I am doing away with for sure, and would not generally recommend,
is "Documents.Add." It creates a new document for each piece of text that is
copied which is not what i want. Instead, I will write to a single file.
--
eugene


"Greg Maxey" wrote:

On Feb 13, 11:39 am, eugene <eug...@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
Hi,

I would like to mark up a text and have a macro select the pieces of text
from one mark to another (eg all text between * to %), copy it and then
paste it into a new file.

Any suggestions on how this can be done neatly?
(I can do the copy/paste part of it. But I don't know how to instruct
selection between the marks. I would suppose one could use find. But know how
to select when finding.)

--
eugene

Maybe something like this:

Sub ScratchMacro()
Dim oRng As Word.Range
Set oRng = ActiveDocument.Range
With oRng.Find
.Text = "[\*]*%"
.Forward = True
.Wrap = wdFindStop
.MatchWildcards = True
While .Execute
'Clip special characters from found text
oRng.Start = oRng.Start + 1
oRng.End = oRng.End - 1
ScratchMacro2 oRng
oRng.Collapse wdCollapseEnd
Wend
End With
End Sub
Sub ScratchMacro2(ByVal oRng2 As Range)
Documents.Add
Selection.Range.Text = oRng2.Text
End Sub





.



Relevant Pages

  • Re: Strange StoryType Behavior
    ... So it is not my unique document or system. ... Greg Maxey/Word MVP ... >> Sub TestStoryType() ... >> Dim oRng As Range ...
    (microsoft.public.word.vba.general)
  • Re: Find and Replace
    ... Thanks for following up, Greg. ... Dim oRng As Word.Range ... Set oRngProcess = Nothing ... Sub ProcessInitials ...
    (microsoft.public.word.newusers)
  • Re: macro to select text from one point to another
    ... I would like to mark up a text and have a macro select the pieces of text ... Dim oRng As Word.Range ... ScratchMacro2 oRng ... Sub ScratchMacro2 ...
    (microsoft.public.word.vba.general)
  • Re: put wordcount for each page on page header automatically
    ... "FotoArt" wrote: ... "Greg Maxey" wrote: ... Dim oDoc As Document ... Dim oRng As Range ...
    (microsoft.public.word.vba.general)
  • Re: List Box Array and coding problem
    ... Thanks for this Greg. ... Dim oRng As Word.Range ... Set oRng = oBM.Range ... Word MVP web site http://word.mvps.org ...
    (microsoft.public.word.vba.general)