#1
|
|||
|
|||
Sanity check on a macro requirement.
I've received a request from my upper management that is wanting the following macro that needs to do the following (it's been a long time since I've worked with vba):
Run a macro that inserts page breaks into a document at every N number of words in the file. For example, given a word count boundary of 1000 words, starting at the beginning of the file, enumerate through and at every word boundary insert a page break. I don't see any built in "goto word position" in Word so I'm guessing simply recording a macro to do this isn't possible. It sounds doable, but just wanted to get an idea of level of difficulty involved and any hurdles (outside of having to refamiliarize myself with the vba development environment) this would impose. thanks in advanced for any help on this. |
#2
|
||||
|
||||
Easy to achieve if you are just going every x words. A bit more complex if you want to find x words then adjust forward or back to a paragraph mark.
Code:
Sub Macro1() Dim x As Long, lStep As Long lStep = 50 'how many words before a page break If ActiveDocument.Words.Count > lStep Then For x = lStep To ActiveDocument.Words.Count Step lStep ActiveDocument.Range.Words(x).InsertAfter Chr(12) Next x End If End Sub
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#3
|
||||
|
||||
Quote:
Note: Word's idea of a 'word' has nothing to do with grammar.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Have a very specific requirement | ggoffice000 | Excel Programming | 2 | 02-03-2017 03:47 PM |
Sanity check | Ulodesk | Word Tables | 2 | 11-01-2016 05:57 AM |
Spell check macro within macro button field doesn't work in one document | samuelle | Word VBA | 0 | 07-20-2016 02:27 AM |
Check Box Macro | Johnny thunder | Word VBA | 12 | 04-07-2011 04:47 PM |
automatic requirement numbering with change detection | stijnos | Word | 0 | 05-13-2009 12:10 AM |