Facebook - Word

L

Levi

Ok so here is the deal. Facebook only allows for 420 character
posts. Word of course has a much higher number of characters one can
enter.

I wrote an article in Word and now I would like it if I had a macro
that could count the characters and break the article into 420
character sections.

Inserting a page break at the 420th character.

Now it gets complicated. Hard stops at 420 characters could lead to a
problem when trying to read the article, as it might cut off a word or
stop mid sentance. So the macro would need logic to go back to the
previous '.' character and insert the page break at that point.

Can anyone do this and send me the macro or VBA code?
(e-mail address removed)
 
D

Doug Robbins - Word MVP

Something like:

Dim i As Long
Dim rng As Range
With ActiveDocument
Set rng = .Range
rng.End = rng.Start + 419
PlayitagainSam:
If Right(rng, 1) <> " " Then
rng.MoveEndUntil Cset:=" ", Count:=wdBackward
End If
rng.Start = rng.End
rng.InsertBefore vbCr
rng.End = rng.Start + 419
If rng.End < .Range.End Then GoTo PlayitagainSam:
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, originally posted via msnews.microsoft.com
 

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