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!
Dave Lett - 04 Oct 2006 19:49 GMT
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
> once i asked in this forum, how could I select the text between 2 marks,
> The
[quoted text clipped - 42 lines]
>
> Can you help me please?thanks!
Laura - 05 Oct 2006 07:46 GMT
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!
> Hi Laura,
> Your sample
[quoted text clipped - 54 lines]
> >
> > Can you help me please?thanks!
Dave Lett - 05 Oct 2006 13:07 GMT
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
> Hi Dave! and thanks for reply the post.
>
[quoted text clipped - 67 lines]
>> >
>> > Can you help me please?thanks!
Laura - 05 Oct 2006 15:12 GMT
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
> Okay,
>
[quoted text clipped - 89 lines]
> >> >
> >> > Can you help me please?thanks!