once i asked in this forum, how could I select the text between 2 marks, The
marks were the first asteristic and the paragraph mark

I wrote an example;
with this text:
P*1.1*Antecedentes*Hasta la fecha actual*
x*a1* este es el anexo primero**17
A*a1* este es el apendice primero

and with the macro that Helmut Weber provided me, I was able to extract, for
example, this text: "1.1*Antecedentes*Hasta la fecha actual*"
I remembered the macro:
--------------------------------------------------
Sub Macro7()
Dim rTMp As Range
Set rTMp = selection.Paragraphs(1).Range
If rTMp.Characters(1) = "x" Then
rTMp.start = rTMp.start + 1
rTMp.End = rTMp.End - 1
rTMp.Select
' which is redundant
' for retrieving the text
MsgBox rTMp
Else
Exit Sub
End If
End Sub
--------------------------------------
it was ok, but now I need that the macro be more general. For example ->the
text between 2 asteristic.
i know to do it with the firs part (that only has a word), but when it has
more than a word, i don't know how to do it.
dim uno as string
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "*"
.Replacement.Text = " * "
End With
Selection.Find.Execute Replace:=wdReplaceOne
uno = ActiveDocument.Paragraphs(3).Range.Words(2)

Can you help me please?thanks!

Re: selecting text II by Dave

Dave
Wed Oct 04 13:49:07 CDT 2006

Hi Laura,

Your sample
P*1.1*Antecedentes*Hasta la fecha actual*
x*a1* este es el anexo primero**17
A*a1* este es el apendice primero

reveals that only the first letter (i.e., "P") and "este es el apendice
primero" are the only things that are NOT between two * symbols. Is that
what you intended?

Dave


"Laura" <Laura@discussions.microsoft.com> wrote in message
news:C12572DD-3F8D-45E6-BD1E-08E88843ADC5@microsoft.com...
> once i asked in this forum, how could I select the text between 2 marks,
> The
> marks were the first asteristic and the paragraph mark
>
> I wrote an example;
> with this text:
> P*1.1*Antecedentes*Hasta la fecha actual*
> x*a1* este es el anexo primero**17
> A*a1* este es el apendice primero
>
> and with the macro that Helmut Weber provided me, I was able to extract,
> for
> example, this text: "1.1*Antecedentes*Hasta la fecha actual*"
> I remembered the macro:
> --------------------------------------------------
> Sub Macro7()
> Dim rTMp As Range
> Set rTMp = selection.Paragraphs(1).Range
> If rTMp.Characters(1) = "x" Then
> rTMp.start = rTMp.start + 1
> rTMp.End = rTMp.End - 1
> rTMp.Select
> ' which is redundant
> ' for retrieving the text
> MsgBox rTMp
> Else
> Exit Sub
> End If
> End Sub
> --------------------------------------
> it was ok, but now I need that the macro be more general. For
> example ->the
> text between 2 asteristic.
> i know to do it with the firs part (that only has a word), but when it has
> more than a word, i don't know how to do it.
> dim uno as string
> Selection.Find.ClearFormatting
> Selection.Find.Replacement.ClearFormatting
> With Selection.Find
> .Text = "*"
> .Replacement.Text = " * "
> End With
> Selection.Find.Execute Replace:=wdReplaceOne
> uno = ActiveDocument.Paragraphs(3).Range.Words(2)
>
> Can you help me please?thanks!



Re: selecting text II by Laura

Laura
Thu Oct 05 01:46:02 CDT 2006

Hi Dave! and thanks for reply the post.

what i need to obtain from the macro (or procedure) is the text between the
* simbols.
perhaps, the solution maybe to place the cursor before the asteristic, and
then get the text's range until the next asteristic, I don't know...

Any idea will be welcome!


"Dave Lett" wrote:

> Hi Laura,
> Your sample
> P*1.1*Antecedentes*Hasta la fecha actual*
> x*a1* este es el anexo primero**17
> A*a1* este es el apendice primero
>
> reveals that only the first letter (i.e., "P") and "este es el apendice
> primero" are the only things that are NOT between two * symbols. Is that
> what you intended?
>
> Dave
>
>
> "Laura" <Laura@discussions.microsoft.com> wrote in message
> news:C12572DD-3F8D-45E6-BD1E-08E88843ADC5@microsoft.com...
> > once i asked in this forum, how could I select the text between 2 marks,
> > The
> > marks were the first asteristic and the paragraph mark
> >
> > I wrote an example;
> > with this text:
> > P*1.1*Antecedentes*Hasta la fecha actual*
> > x*a1* este es el anexo primero**17
> > A*a1* este es el apendice primero
> >
> > and with the macro that Helmut Weber provided me, I was able to extract,
> > for
> > example, this text: "1.1*Antecedentes*Hasta la fecha actual*"
> > I remembered the macro:
> > --------------------------------------------------
> > Sub Macro7()
> > Dim rTMp As Range
> > Set rTMp = selection.Paragraphs(1).Range
> > If rTMp.Characters(1) = "x" Then
> > rTMp.start = rTMp.start + 1
> > rTMp.End = rTMp.End - 1
> > rTMp.Select
> > ' which is redundant
> > ' for retrieving the text
> > MsgBox rTMp
> > Else
> > Exit Sub
> > End If
> > End Sub
> > --------------------------------------
> > it was ok, but now I need that the macro be more general. For
> > example ->the
> > text between 2 asteristic.
> > i know to do it with the firs part (that only has a word), but when it has
> > more than a word, i don't know how to do it.
> > dim uno as string
> > Selection.Find.ClearFormatting
> > Selection.Find.Replacement.ClearFormatting
> > With Selection.Find
> > .Text = "*"
> > .Replacement.Text = " * "
> > End With
> > Selection.Find.Execute Replace:=wdReplaceOne
> > uno = ActiveDocument.Paragraphs(3).Range.Words(2)
> >
> > Can you help me please?thanks!
>
>
>

Re: selecting text II by Dave

Dave
Thu Oct 05 07:07:50 CDT 2006

Okay,

This is what you asked for:

Dim sString As String
With Selection
.HomeKey Unit:=wdStory
With .Find
.ClearFormatting
.Text = "\*(*)\*"
.MatchWildcards = True
Do While .Execute
Debug.Print Replace(Selection.Text, "*", "")
Selection.Characters.Last.Select
Selection.MoveLeft
Loop
End With
End With


HTH,
Dave

"Laura" <Laura@discussions.microsoft.com> wrote in message
news:7E8332FD-3850-4427-BFA4-2F2B57BEE7E8@microsoft.com...
> Hi Dave! and thanks for reply the post.
>
> what i need to obtain from the macro (or procedure) is the text between
> the
> * simbols.
> perhaps, the solution maybe to place the cursor before the asteristic, and
> then get the text's range until the next asteristic, I don't know...
>
> Any idea will be welcome!
>
>
> "Dave Lett" wrote:
>
>> Hi Laura,
>> Your sample
>> P*1.1*Antecedentes*Hasta la fecha actual*
>> x*a1* este es el anexo primero**17
>> A*a1* este es el apendice primero
>>
>> reveals that only the first letter (i.e., "P") and "este es el apendice
>> primero" are the only things that are NOT between two * symbols. Is that
>> what you intended?
>>
>> Dave
>>
>>
>> "Laura" <Laura@discussions.microsoft.com> wrote in message
>> news:C12572DD-3F8D-45E6-BD1E-08E88843ADC5@microsoft.com...
>> > once i asked in this forum, how could I select the text between 2
>> > marks,
>> > The
>> > marks were the first asteristic and the paragraph mark
>> >
>> > I wrote an example;
>> > with this text:
>> > P*1.1*Antecedentes*Hasta la fecha actual*
>> > x*a1* este es el anexo primero**17
>> > A*a1* este es el apendice primero
>> >
>> > and with the macro that Helmut Weber provided me, I was able to
>> > extract,
>> > for
>> > example, this text: "1.1*Antecedentes*Hasta la fecha actual*"
>> > I remembered the macro:
>> > --------------------------------------------------
>> > Sub Macro7()
>> > Dim rTMp As Range
>> > Set rTMp = selection.Paragraphs(1).Range
>> > If rTMp.Characters(1) = "x" Then
>> > rTMp.start = rTMp.start + 1
>> > rTMp.End = rTMp.End - 1
>> > rTMp.Select
>> > ' which is redundant
>> > ' for retrieving the text
>> > MsgBox rTMp
>> > Else
>> > Exit Sub
>> > End If
>> > End Sub
>> > --------------------------------------
>> > it was ok, but now I need that the macro be more general. For
>> > example ->the
>> > text between 2 asteristic.
>> > i know to do it with the firs part (that only has a word), but when it
>> > has
>> > more than a word, i don't know how to do it.
>> > dim uno as string
>> > Selection.Find.ClearFormatting
>> > Selection.Find.Replacement.ClearFormatting
>> > With Selection.Find
>> > .Text = "*"
>> > .Replacement.Text = " * "
>> > End With
>> > Selection.Find.Execute Replace:=wdReplaceOne
>> > uno = ActiveDocument.Paragraphs(3).Range.Words(2)
>> >
>> > Can you help me please?thanks!
>>
>>
>>



Re: selecting text II by Laura

Laura
Thu Oct 05 09:12:01 CDT 2006

Dave
It works fine! I'm very grateful for your help. I'm a beginner programmer in
vba. And your help has been very important for me.

I hope some day I'm enough level to answer your questions

"Dave Lett" wrote:

> Okay,
>
> This is what you asked for:
>
> Dim sString As String
> With Selection
> .HomeKey Unit:=wdStory
> With .Find
> .ClearFormatting
> .Text = "\*(*)\*"
> .MatchWildcards = True
> Do While .Execute
> Debug.Print Replace(Selection.Text, "*", "")
> Selection.Characters.Last.Select
> Selection.MoveLeft
> Loop
> End With
> End With
>
>
> HTH,
> Dave
>
> "Laura" <Laura@discussions.microsoft.com> wrote in message
> news:7E8332FD-3850-4427-BFA4-2F2B57BEE7E8@microsoft.com...
> > Hi Dave! and thanks for reply the post.
> >
> > what i need to obtain from the macro (or procedure) is the text between
> > the
> > * simbols.
> > perhaps, the solution maybe to place the cursor before the asteristic, and
> > then get the text's range until the next asteristic, I don't know...
> >
> > Any idea will be welcome!
> >
> >
> > "Dave Lett" wrote:
> >
> >> Hi Laura,
> >> Your sample
> >> P*1.1*Antecedentes*Hasta la fecha actual*
> >> x*a1* este es el anexo primero**17
> >> A*a1* este es el apendice primero
> >>
> >> reveals that only the first letter (i.e., "P") and "este es el apendice
> >> primero" are the only things that are NOT between two * symbols. Is that
> >> what you intended?
> >>
> >> Dave
> >>
> >>
> >> "Laura" <Laura@discussions.microsoft.com> wrote in message
> >> news:C12572DD-3F8D-45E6-BD1E-08E88843ADC5@microsoft.com...
> >> > once i asked in this forum, how could I select the text between 2
> >> > marks,
> >> > The
> >> > marks were the first asteristic and the paragraph mark
> >> >
> >> > I wrote an example;
> >> > with this text:
> >> > P*1.1*Antecedentes*Hasta la fecha actual*
> >> > x*a1* este es el anexo primero**17
> >> > A*a1* este es el apendice primero
> >> >
> >> > and with the macro that Helmut Weber provided me, I was able to
> >> > extract,
> >> > for
> >> > example, this text: "1.1*Antecedentes*Hasta la fecha actual*"
> >> > I remembered the macro:
> >> > --------------------------------------------------
> >> > Sub Macro7()
> >> > Dim rTMp As Range
> >> > Set rTMp = selection.Paragraphs(1).Range
> >> > If rTMp.Characters(1) = "x" Then
> >> > rTMp.start = rTMp.start + 1
> >> > rTMp.End = rTMp.End - 1
> >> > rTMp.Select
> >> > ' which is redundant
> >> > ' for retrieving the text
> >> > MsgBox rTMp
> >> > Else
> >> > Exit Sub
> >> > End If
> >> > End Sub
> >> > --------------------------------------
> >> > it was ok, but now I need that the macro be more general. For
> >> > example ->the
> >> > text between 2 asteristic.
> >> > i know to do it with the firs part (that only has a word), but when it
> >> > has
> >> > more than a word, i don't know how to do it.
> >> > dim uno as string
> >> > Selection.Find.ClearFormatting
> >> > Selection.Find.Replacement.ClearFormatting
> >> > With Selection.Find
> >> > .Text = "*"
> >> > .Replacement.Text = " * "
> >> > End With
> >> > Selection.Find.Execute Replace:=wdReplaceOne
> >> > uno = ActiveDocument.Paragraphs(3).Range.Words(2)
> >> >
> >> > Can you help me please?thanks!
> >>
> >>
> >>
>
>
>