![]() |
#1
|
|||
|
|||
![]()
Does anybody know of a macro that will highlight a specific number of words based on a numeric input in MS Word?
For instance, I would like to enter a number in a dialog box, such as 250, and have 250 words hightlighted in a document that I can then copy or delete. I know I can manually highlight words to get a count, but I sometimes have to highlight an odd number such as 537 words, and I always either go too far or not far enough and it gets frustrating. Thanks. |
#2
|
||||
|
||||
![]()
hi icsjohn,
Try the following macro. It counts from the start of the selected range and doesn't care whether the current selection is more, or less, than the desired word count. Code:
Sub Demo() Dim i As Long i = InputBox("How many words do you want to select?", "Word Marker") With Selection While .Range.ComputeStatistics(Statistic:=wdStatisticWords) < i .MoveEnd wdWord, i - .Range.ComputeStatistics(Statistic:=wdStatisticWords) Wend End With End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
![]()
This worked perfectly. Thank you very much.
|
![]() |
Tags |
highlight, macro, word count |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
flackend | Mail Merge | 4 | 12-01-2023 02:49 PM |
![]() |
kimsi | Word | 3 | 11-15-2011 11:54 PM |
![]() |
Jamal NUMAN | Word | 24 | 07-24-2011 04:39 PM |
![]() |
zsmithku | Word | 1 | 04-15-2011 03:46 PM |
Why Words doesn’t show the style of the selected words automatically???? | Jamal NUMAN | Word | 0 | 04-14-2011 03:20 PM |