SELECTION BETWEEN

M

MarcoPolo

i need to select a part of a text of an active document starting from "A)"
till "B)"
and copying this selection into a text file

i know how to use txt files but how can i select ?
 
D

Dave Lett

Hi,

You can use something like the following:

Dim oRngStart As Range
Dim oRngEnd As Range
Dim oRngToCopy As Range
With Selection
.HomeKey Unit:=wdStory
With .Find
.ClearFormatting
.Text = "A)"
.Execute

Set oRngStart = Selection.Range
Selection.MoveRight

.Text = "B)"
.Execute
Set oRngEnd = Selection.Range
End With
End With

Set oRngToCopy = ActiveDocument.Range(Start:=oRngStart.End,
End:=oRngEnd.Start)
oRngToCopy.Select

HTH,
Dave
 

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