Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Word
application.errors
conversions
docmanagement
drawing.graphics
formatting.longdocs
international
internet.assistant
mail
mailmerge.fields
menustoolbars
newusers
numbering
oleinterop
pagelayout
printingfonts
setup.networking
spelling.grammar
tables
vba.addins
vba.beginners
vba.customization
vba.general
vba.userforms
web.authoring
word6-7macros
word97vba
  
 
date: Sat, 4 Oct 2008 03:19:40 -0700 (PDT),    group: microsoft.public.word.vba.general        back       


How to extract some text from list in some order?   
Hello.
There is one document which has many numbered paragraphs (from 1 to 50
or different). I need to get from this list of some paragraphs
together for next order: 1 and 31, 2 and 32...30 and 50.
For example:
The number list view like:
1. Some text some text.
2. Other some text.
3. And more other text.
...
30. My some text.
31. My other some text.
32. My new other text.
...
50. Some text.

I heed to get it so:
1. Some text some text.
31. My other some text.

2. Other some text.
32. My new other text.

30. My some text.
50. Some text.

First I convert the numbered list to plain text. But what I should to
do next I'm not know. Maybe create array from selection text?
Help me, please.
Thank you very much.
date: Sat, 4 Oct 2008 03:19:40 -0700 (PDT)   author:   avkokin

Re: How to extract some text from list in some order?   
Set a Range object to the list and then extract the required paragraphs

Dim OldList as Range
Set OldList = [the range of text that includes the list]
Set NewList = ActiveDocument.Range
NewList.Collapse wdCollapseEnd
With NewList
    InsertAfter OldList.Paragraphs(1).Range & OldList.Paragraphs(31).Range & 
etc.
End With




-- 
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"avkokin"  wrote in message 
news:f0ae03c7-ece4-4df4-9f2e-6b17497500e5@w32g2000hsf.googlegroups.com...
> Hello.
> There is one document which has many numbered paragraphs (from 1 to 50
> or different). I need to get from this list of some paragraphs
> together for next order: 1 and 31, 2 and 32...30 and 50.
> For example:
> The number list view like:
> 1. Some text some text.
> 2. Other some text.
> 3. And more other text.
> ...
> 30. My some text.
> 31. My other some text.
> 32. My new other text.
> ...
> 50. Some text.
>
> I heed to get it so:
> 1. Some text some text.
> 31. My other some text.
>
> 2. Other some text.
> 32. My new other text.
>
> 30. My some text.
> 50. Some text.
>
> First I convert the numbered list to plain text. But what I should to
> do next I'm not know. Maybe create array from selection text?
> Help me, please.
> Thank you very much.
date: Sun, 5 Oct 2008 05:53:03 +1000   author:   Doug Robbins - Word MVP

Re: How to extract some text from list in some order?   
Hi. Sorry but if I set for range Selection.Range I got error. This my code:

Sub test_bilet()
Dim NewList As Range
Dim OldList As Range
Set OldList = Selection.Range
Set NewList = ActiveDocument.Range
NewList.Collapse wdCollapseEnd
With NewList
   InsertAfter OldList.Paragraphs(1).Range & OldList.Paragraphs(31).Range & 
vbCr
   InsertAfter OldList.Paragraphs(2).Range & OldList.Paragraphs(32).Range & 
vbCr
   InsertAfter OldList.Paragraphs(3).Range & OldList.Paragraphs(33).Range & 
vbCr
   InsertAfter OldList.Paragraphs(4).Range & OldList.Paragraphs(34).Range & 
vbCr
   InsertAfter OldList.Paragraphs(5).Range & OldList.Paragraphs(35).Range & 
vbCr
   InsertAfter OldList.Paragraphs(6).Range & OldList.Paragraphs(36).Range & 
vbCr
   InsertAfter OldList.Paragraphs(7).Range & OldList.Paragraphs(37).Range & 
vbCr
   InsertAfter OldList.Paragraphs(8).Range & OldList.Paragraphs(38).Range & 
vbCr
   InsertAfter OldList.Paragraphs(9).Range & OldList.Paragraphs(39).Range & 
vbCr
   InsertAfter OldList.Paragraphs(10).Range & OldList.Paragraphs(40).Range & 
vbCr
   InsertAfter OldList.Paragraphs(11).Range & OldList.Paragraphs(41).Range & 
vbCr
   InsertAfter OldList.Paragraphs(12).Range & OldList.Paragraphs(42).Range & 
vbCr
   InsertAfter OldList.Paragraphs(13).Range & OldList.Paragraphs(43).Range & 
vbCr
   InsertAfter OldList.Paragraphs(14).Range & OldList.Paragraphs(44).Range & 
vbCr
   InsertAfter OldList.Paragraphs(15).Range & OldList.Paragraphs(45).Range & 
vbCr
   InsertAfter OldList.Paragraphs(16).Range & OldList.Paragraphs(46).Range & 
vbCr
   InsertAfter OldList.Paragraphs(17).Range & OldList.Paragraphs(47).Range & 
vbCr
   InsertAfter OldList.Paragraphs(18).Range & OldList.Paragraphs(48).Range & 
vbCr
   InsertAfter OldList.Paragraphs(19).Range & OldList.Paragraphs(49).Range & 
vbCr
End With
End Sub
date: Sun, 5 Oct 2008 08:43:56 +0400   author:   Anton Kokin

Re: How to extract some text from list in some order?   
What line of code causes the error?

-- 
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Anton Kokin"  wrote in message 
news:OqPc7TqJJHA.3460@TK2MSFTNGP04.phx.gbl...
> Hi. Sorry but if I set for range Selection.Range I got error. This my 
> code:
>
> Sub test_bilet()
> Dim NewList As Range
> Dim OldList As Range
> Set OldList = Selection.Range
> Set NewList = ActiveDocument.Range
> NewList.Collapse wdCollapseEnd
> With NewList
>   InsertAfter OldList.Paragraphs(1).Range & OldList.Paragraphs(31).Range & 
> vbCr
>   InsertAfter OldList.Paragraphs(2).Range & OldList.Paragraphs(32).Range & 
> vbCr
>   InsertAfter OldList.Paragraphs(3).Range & OldList.Paragraphs(33).Range & 
> vbCr
>   InsertAfter OldList.Paragraphs(4).Range & OldList.Paragraphs(34).Range & 
> vbCr
>   InsertAfter OldList.Paragraphs(5).Range & OldList.Paragraphs(35).Range & 
> vbCr
>   InsertAfter OldList.Paragraphs(6).Range & OldList.Paragraphs(36).Range & 
> vbCr
>   InsertAfter OldList.Paragraphs(7).Range & OldList.Paragraphs(37).Range & 
> vbCr
>   InsertAfter OldList.Paragraphs(8).Range & OldList.Paragraphs(38).Range & 
> vbCr
>   InsertAfter OldList.Paragraphs(9).Range & OldList.Paragraphs(39).Range & 
> vbCr
>   InsertAfter OldList.Paragraphs(10).Range & OldList.Paragraphs(40).Range 
> & vbCr
>   InsertAfter OldList.Paragraphs(11).Range & OldList.Paragraphs(41).Range 
> & vbCr
>   InsertAfter OldList.Paragraphs(12).Range & OldList.Paragraphs(42).Range 
> & vbCr
>   InsertAfter OldList.Paragraphs(13).Range & OldList.Paragraphs(43).Range 
> & vbCr
>   InsertAfter OldList.Paragraphs(14).Range & OldList.Paragraphs(44).Range 
> & vbCr
>   InsertAfter OldList.Paragraphs(15).Range & OldList.Paragraphs(45).Range 
> & vbCr
>   InsertAfter OldList.Paragraphs(16).Range & OldList.Paragraphs(46).Range 
> & vbCr
>   InsertAfter OldList.Paragraphs(17).Range & OldList.Paragraphs(47).Range 
> & vbCr
>   InsertAfter OldList.Paragraphs(18).Range & OldList.Paragraphs(48).Range 
> & vbCr
>   InsertAfter OldList.Paragraphs(19).Range & OldList.Paragraphs(49).Range 
> & vbCr
> End With
> End Sub
>
date: Sun, 5 Oct 2008 19:40:18 +1000   author:   Doug Robbins - Word MVP

Re: How to extract some text from list in some order?   
If you select the range of paragraphs and then run the following code, it 
will sort them into the order that you want (deleting paragraphs 20 through 
29, which did not appear to be used in your code)

Dim i As Long
Selection.Range.ConvertToTable
With Selection.Tables(1)
    .Columns.Add BeforeColumn:=.Columns(1)
    With .Columns(1)
        For i = 1 To 19
            .Cells(i).Range.Text = 2 * i - 1
        Next i
        For i = 30 To 49
            .Cells(i).Range.Text = 2 * (i - 29)
        Next i
    End With
    For i = 29 To 20 Step -1
        .Rows(i).Delete
    Next i
    .Sort
    .Columns(1).Delete
End With



-- 
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Anton Kokin"  wrote in message 
news:OqPc7TqJJHA.3460@TK2MSFTNGP04.phx.gbl...
> Hi. Sorry but if I set for range Selection.Range I got error. This my 
> code:
>
> Sub test_bilet()
> Dim NewList As Range
> Dim OldList As Range
> Set OldList = Selection.Range
> Set NewList = ActiveDocument.Range
> NewList.Collapse wdCollapseEnd
> With NewList
>   InsertAfter OldList.Paragraphs(1).Range & OldList.Paragraphs(31).Range & 
> vbCr
>   InsertAfter OldList.Paragraphs(2).Range & OldList.Paragraphs(32).Range & 
> vbCr
>   InsertAfter OldList.Paragraphs(3).Range & OldList.Paragraphs(33).Range & 
> vbCr
>   InsertAfter OldList.Paragraphs(4).Range & OldList.Paragraphs(34).Range & 
> vbCr
>   InsertAfter OldList.Paragraphs(5).Range & OldList.Paragraphs(35).Range & 
> vbCr
>   InsertAfter OldList.Paragraphs(6).Range & OldList.Paragraphs(36).Range & 
> vbCr
>   InsertAfter OldList.Paragraphs(7).Range & OldList.Paragraphs(37).Range & 
> vbCr
>   InsertAfter OldList.Paragraphs(8).Range & OldList.Paragraphs(38).Range & 
> vbCr
>   InsertAfter OldList.Paragraphs(9).Range & OldList.Paragraphs(39).Range & 
> vbCr
>   InsertAfter OldList.Paragraphs(10).Range & OldList.Paragraphs(40).Range 
> & vbCr
>   InsertAfter OldList.Paragraphs(11).Range & OldList.Paragraphs(41).Range 
> & vbCr
>   InsertAfter OldList.Paragraphs(12).Range & OldList.Paragraphs(42).Range 
> & vbCr
>   InsertAfter OldList.Paragraphs(13).Range & OldList.Paragraphs(43).Range 
> & vbCr
>   InsertAfter OldList.Paragraphs(14).Range & OldList.Paragraphs(44).Range 
> & vbCr
>   InsertAfter OldList.Paragraphs(15).Range & OldList.Paragraphs(45).Range 
> & vbCr
>   InsertAfter OldList.Paragraphs(16).Range & OldList.Paragraphs(46).Range 
> & vbCr
>   InsertAfter OldList.Paragraphs(17).Range & OldList.Paragraphs(47).Range 
> & vbCr
>   InsertAfter OldList.Paragraphs(18).Range & OldList.Paragraphs(48).Range 
> & vbCr
>   InsertAfter OldList.Paragraphs(19).Range & OldList.Paragraphs(49).Range 
> & vbCr
> End With
> End Sub
>
date: Sun, 5 Oct 2008 20:07:53 +1000   author:   Doug Robbins - Word MVP

Re: How to extract some text from list in some order?   
the error is "Sub or Function not defined" for property "Range" by 
OldList.Paragraphs(1)>Range:

>>   InsertAfter OldList.Paragraphs(1).Range & OldList.Paragraphs(31).Range 
>> &

I selection text of numbered lis and apply this macro.
date: Sun, 5 Oct 2008 14:17:43 +0400   author:   Anton Kokin

Re: How to extract some text from list in some order?   
Hi Doug.
Thank you very much for your help but it is not that I want. Sorry. The 
result is the table and sort uncorrect. I think would use the array for 
selection text:
set arr = Split(Selection.Text, Chr(13))
Next should somehow divide it on 2 part (maybe so UBound (arr)/2) ?) and 
take out need lines and join it in correct order: 1 and 31, 2 and 32...30 
and 60 etc.

Thank you very much!

"Doug Robbins - Word MVP"  ÓÏÏÂÝÉÌ/ÓÏÏÂÝÉÌÁ × 
ÎÏ×ÏÓÔÑÈ ÓÌÅÄÕÀÝÅÅ: news:efCd%23ItJJHA.5060@TK2MSFTNGP02.phx.gbl...
> If you select the range of paragraphs and then run the following code, it 
> will sort them into the order that you want (deleting paragraphs 20 
> through 29, which did not appear to be used in your code)
>
> Dim i As Long
> Selection.Range.ConvertToTable
> With Selection.Tables(1)
>    .Columns.Add BeforeColumn:=.Columns(1)
>    With .Columns(1)
>        For i = 1 To 19
>            .Cells(i).Range.Text = 2 * i - 1
>        Next i
>        For i = 30 To 49
>            .Cells(i).Range.Text = 2 * (i - 29)
>        Next i
>    End With
>    For i = 29 To 20 Step -1
>        .Rows(i).Delete
>    Next i
>    .Sort
>    .Columns(1).Delete
> End With
>
>
>
> -- 
> Hope this helps.
>
> Please reply to the newsgroup unless you wish to avail yourself of my
> services on a paid consulting basis.
>
> Doug Robbins - Word MVP
>
> "Anton Kokin"  wrote in message 
> news:OqPc7TqJJHA.3460@TK2MSFTNGP04.phx.gbl...
>> Hi. Sorry but if I set for range Selection.Range I got error. This my 
>> code:
>>
>> Sub test_bilet()
>> Dim NewList As Range
>> Dim OldList As Range
>> Set OldList = Selection.Range
>> Set NewList = ActiveDocument.Range
>> NewList.Collapse wdCollapseEnd
>> With NewList
>>   InsertAfter OldList.Paragraphs(1).Range & OldList.Paragraphs(31).Range 
>> & vbCr
>>   InsertAfter OldList.Paragraphs(2).Range & OldList.Paragraphs(32).Range 
>> & vbCr
>>   InsertAfter OldList.Paragraphs(3).Range & OldList.Paragraphs(33).Range 
>> & vbCr
>>   InsertAfter OldList.Paragraphs(4).Range & OldList.Paragraphs(34).Range 
>> & vbCr
>>   InsertAfter OldList.Paragraphs(5).Range & OldList.Paragraphs(35).Range 
>> & vbCr
>>   InsertAfter OldList.Paragraphs(6).Range & OldList.Paragraphs(36).Range 
>> & vbCr
>>   InsertAfter OldList.Paragraphs(7).Range & OldList.Paragraphs(37).Range 
>> & vbCr
>>   InsertAfter OldList.Paragraphs(8).Range & OldList.Paragraphs(38).Range 
>> & vbCr
>>   InsertAfter OldList.Paragraphs(9).Range & OldList.Paragraphs(39).Range 
>> & vbCr
>>   InsertAfter OldList.Paragraphs(10).Range & OldList.Paragraphs(40).Range 
>> & vbCr
>>   InsertAfter OldList.Paragraphs(11).Range & OldList.Paragraphs(41).Range 
>> & vbCr
>>   InsertAfter OldList.Paragraphs(12).Range & OldList.Paragraphs(42).Range 
>> & vbCr
>>   InsertAfter OldList.Paragraphs(13).Range & OldList.Paragraphs(43).Range 
>> & vbCr
>>   InsertAfter OldList.Paragraphs(14).Range & OldList.Paragraphs(44).Range 
>> & vbCr
>>   InsertAfter OldList.Paragraphs(15).Range & OldList.Paragraphs(45).Range 
>> & vbCr
>>   InsertAfter OldList.Paragraphs(16).Range & OldList.Paragraphs(46).Range 
>> & vbCr
>>   InsertAfter OldList.Paragraphs(17).Range & OldList.Paragraphs(47).Range 
>> & vbCr
>>   InsertAfter OldList.Paragraphs(18).Range & OldList.Paragraphs(48).Range 
>> & vbCr
>>   InsertAfter OldList.Paragraphs(19).Range & OldList.Paragraphs(49).Range 
>> & vbCr
>> End With
>> End Sub
>>
>
>
date: Thu, 9 Oct 2008 16:31:27 +0400   author:   akokin

Re: How to extract some text from list in some order?   
It works correctly here as a substitute for what you were trying to do with 
the code that you posted.

-- 
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"akokin"  wrote in message 
news:uzv2yrgKJHA.456@TK2MSFTNGP06.phx.gbl...
> Hi Doug.
> Thank you very much for your help but it is not that I want. Sorry. The 
> result is the table and sort uncorrect. I think would use the array for 
> selection text:
> set arr = Split(Selection.Text, Chr(13))
> Next should somehow divide it on 2 part (maybe so UBound (arr)/2) ?) and 
> take out need lines and join it in correct order: 1 and 31, 2 and 32...30 
> and 60 etc.
>
> Thank you very much!
>
> "Doug Robbins - Word MVP"  ÓÏÏÂÝÉÌ/ÓÏÏÂÝÉÌÁ × 
> ÎÏ×ÏÓÔÑÈ ÓÌÅÄÕÀÝÅÅ: news:efCd%23ItJJHA.5060@TK2MSFTNGP02.phx.gbl...
>> If you select the range of paragraphs and then run the following code, it 
>> will sort them into the order that you want (deleting paragraphs 20 
>> through 29, which did not appear to be used in your code)
>>
>> Dim i As Long
>> Selection.Range.ConvertToTable
>> With Selection.Tables(1)
>>    .Columns.Add BeforeColumn:=.Columns(1)
>>    With .Columns(1)
>>        For i = 1 To 19
>>            .Cells(i).Range.Text = 2 * i - 1
>>        Next i
>>        For i = 30 To 49
>>            .Cells(i).Range.Text = 2 * (i - 29)
>>        Next i
>>    End With
>>    For i = 29 To 20 Step -1
>>        .Rows(i).Delete
>>    Next i
>>    .Sort
>>    .Columns(1).Delete
>> End With
>>
>>
>>
>> -- 
>> Hope this helps.
>>
>> Please reply to the newsgroup unless you wish to avail yourself of my
>> services on a paid consulting basis.
>>
>> Doug Robbins - Word MVP
>>
>> "Anton Kokin"  wrote in message 
>> news:OqPc7TqJJHA.3460@TK2MSFTNGP04.phx.gbl...
>>> Hi. Sorry but if I set for range Selection.Range I got error. This my 
>>> code:
>>>
>>> Sub test_bilet()
>>> Dim NewList As Range
>>> Dim OldList As Range
>>> Set OldList = Selection.Range
>>> Set NewList = ActiveDocument.Range
>>> NewList.Collapse wdCollapseEnd
>>> With NewList
>>>   InsertAfter OldList.Paragraphs(1).Range & OldList.Paragraphs(31).Range 
>>> & vbCr
>>>   InsertAfter OldList.Paragraphs(2).Range & OldList.Paragraphs(32).Range 
>>> & vbCr
>>>   InsertAfter OldList.Paragraphs(3).Range & OldList.Paragraphs(33).Range 
>>> & vbCr
>>>   InsertAfter OldList.Paragraphs(4).Range & OldList.Paragraphs(34).Range 
>>> & vbCr
>>>   InsertAfter OldList.Paragraphs(5).Range & OldList.Paragraphs(35).Range 
>>> & vbCr
>>>   InsertAfter OldList.Paragraphs(6).Range & OldList.Paragraphs(36).Range 
>>> & vbCr
>>>   InsertAfter OldList.Paragraphs(7).Range & OldList.Paragraphs(37).Range 
>>> & vbCr
>>>   InsertAfter OldList.Paragraphs(8).Range & OldList.Paragraphs(38).Range 
>>> & vbCr
>>>   InsertAfter OldList.Paragraphs(9).Range & OldList.Paragraphs(39).Range 
>>> & vbCr
>>>   InsertAfter OldList.Paragraphs(10).Range & 
>>> OldList.Paragraphs(40).Range & vbCr
>>>   InsertAfter OldList.Paragraphs(11).Range & 
>>> OldList.Paragraphs(41).Range & vbCr
>>>   InsertAfter OldList.Paragraphs(12).Range & 
>>> OldList.Paragraphs(42).Range & vbCr
>>>   InsertAfter OldList.Paragraphs(13).Range & 
>>> OldList.Paragraphs(43).Range & vbCr
>>>   InsertAfter OldList.Paragraphs(14).Range & 
>>> OldList.Paragraphs(44).Range & vbCr
>>>   InsertAfter OldList.Paragraphs(15).Range & 
>>> OldList.Paragraphs(45).Range & vbCr
>>>   InsertAfter OldList.Paragraphs(16).Range & 
>>> OldList.Paragraphs(46).Range & vbCr
>>>   InsertAfter OldList.Paragraphs(17).Range & 
>>> OldList.Paragraphs(47).Range & vbCr
>>>   InsertAfter OldList.Paragraphs(18).Range & 
>>> OldList.Paragraphs(48).Range & vbCr
>>>   InsertAfter OldList.Paragraphs(19).Range & 
>>> OldList.Paragraphs(49).Range & vbCr
>>> End With
>>> End Sub
>>>
>>
>>
>
>
date: Fri, 10 Oct 2008 05:51:11 +1000   author:   Doug Robbins - Word MVP

Re: How to extract some text from list in some order?   
Hi Doug. Thank you very much. Maybe I simple unable to work with
tables and sort.
I found some other way for my task:
Sub listM()
Dim arr() As String
Dim rng As Range
Dim i As Long

Set rng = Selection.Range
'rng.ListFormat.ConvertNumbersToText
arr = Split(rng, Chr(13))

For i = 0 To UBound(arr) / 2
    Debug.Print arr(i) & vbCrLf
    Debug.Print arr(i + (UBound(arr) / 2) - 1) & vbCrLf
Next i
End Sub

Your help was much appreciated.
Sincerely, Anton Kokin.
date: Thu, 9 Oct 2008 23:13:28 -0700 (PDT)   author:   avkokin

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us