>Hi Colin,
>
[quoted text clipped - 10 lines]
>Regards,
>Jay Freedman
Hi Jay
Thanks for getting back.
I'm actually splitting a variety of passages of varying lengths so I can
paste the sections into Access. The maximum it will allow in any one
cell is 250 characters. That's the reason for the split at that point. I
would paste each part into consecutive cells in Access.
As the size of the passage I'm splitting will vary , it may be that if
it's less than 250 then it won't have to split it in any case. Also ,
as it comes to the last section it will be that this has fewer than the
250 characters. These would be the reasons why it might need to split at
somewhere other than 250 characters. The macro would need to recognise
that the split would be at up to 250 , but not fall over if it's less.
If you see what I mean!
It would have to count characters and space and divide accordingly. A
passage of 300 characters would give two paragraphs of 250 and 50
separated on the page. And so on. A passage of less than 250 would be
left as is.
It would very useful to run a macro which would divide whichever length
of passage it finds into parts of 250 , and a remainder paragraph and
then just arrange them with a double space between each so I can paste
from there. I'm not sure I'm using the word 'section' in the 'Word'
sense here - you're right on that.
Grateful if you can help.
Best Wishes
Colin
>Microsoft Word MVP FAQ: http://word.mvps.org
>
[quoted text clipped - 13 lines]
>>
>>Colin
Jay Freedman - 29 Dec 2006 05:35 GMT
>>Hi Colin,
>>
[quoted text clipped - 44 lines]
>
>Colin
The following macro will separate the text into as many chunks to 250
characters as possible, leaving the final chunk at whatever smaller
size is necessary. The separation is two paragraph marks, which aren't
counted in the 250 characters. If the split point occurs in the middle
of a word, that's where the paragraph marks will be inserted -- if you
want the macro to look for spaces between words and only split there,
that's a bit more work.
Sub SplitIntoChunks()
Const chunkSize = 250
Dim oRg As Range
Dim actualSize As Long
Set oRg = ActiveDocument.Range
With oRg
.Collapse wdCollapseStart
actualSize = .MoveEnd(Unit:=wdCharacter, Count:=chunkSize)
Do While actualSize = chunkSize
.InsertAfter vbCr & vbCr
.Collapse wdCollapseEnd
actualSize = .MoveEnd(Unit:=wdCharacter, Count:=chunkSize)
Loop
End With
End Sub
--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org