Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Sort without "the" or "a"
I want to sort a list of titles, but items such as "The ABC" should be under
A not T. How do I do this? |
#2
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Sort without "the" or "a"
Word doesn't provide a way to do this unless you either put "The" after the
title ("ABC, The") or temporarily format "The" and A" as Hidden Text, hide them, sort, and then remove the Hidden property. -- Suzanne S. Barnhill Microsoft MVP (Word) Words into Type Fairhope, Alabama USA http://word.mvps.org "lilac" wrote in message ... I want to sort a list of titles, but items such as "The ABC" should be under A not T. How do I do this? |
#3
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Sort without "the" or "a"
lilac,
Manually ;-) AFAIK, you will have to convert "The ABC" to "ABC, The" and things like "A Nation" to "Nation, A" before sorting. You do it with a macro. Selecti your list paragraphs and run this code: Sub ScratchMaco() Dim oRng As Word.Range Dim oPar As Paragraph Dim oRngProcess Dim pStr As String Set oRng = Selection.Range For Each oPar In oRng.Paragraphs Select Case oPar.Range.Words.First Case "The ", "A " pStr = ", " & Trim(oPar.Range.Words.First) oPar.Range.Words.First.Delete Set oRngProcess = oPar.Range oRngProcess.Collapse wdCollapseEnd oRngProcess.MoveEnd wdCharacter, -1 oRngProcess.InsertAfter pStr End Select Next Selection.Sort End Sub http://www.gmayor.com/installing_macro.htm lilac wrote: I want to sort a list of titles, but items such as "The ABC" should be under A not T. How do I do this? -- Greg Maxey See my web site http://gregmaxey.mvps.org for an eclectic collection of Word Tips. Arrogance is a weed that grows mostly on a dunghill (Arabic proverb) |
#4
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Sort without "the" or "a"
Ms. Barnhill,
Second option very neat. Learn something new everyday. You can also do that with nails and hammers ;-) Sub ScratchMacoII() Dim oRng As Word.Range Dim oPar As Paragraph Dim oRngProcess Dim pStr As String Set oRng = Selection.Range For Each oPar In oRng.Paragraphs Select Case oPar.Range.Words.First Case "The ", "A " oPar.Range.Words.First.Font.Hidden = True oPar.Range.Shading.BackgroundPatternColorIndex = wdBrightGreen End Select Next Selection.Sort For Each oPar In oRng.Paragraphs Select Case oPar.Range.Shading.BackgroundPatternColorIndex Case wdBrightGreen oPar.Range.Words.First.Font.Hidden = False oPar.Range.Shading.BackgroundPatternColorIndex = wdAuto End Select Next End Sub ***Assumes of course that no paragraphs shading is used in the original text. Suzanne S. Barnhill wrote: Word doesn't provide a way to do this unless you either put "The" after the title ("ABC, The") or temporarily format "The" and A" as Hidden Text, hide them, sort, and then remove the Hidden property. "lilac" wrote in message ... I want to sort a list of titles, but items such as "The ABC" should be under A not T. How do I do this? -- Greg Maxey See my web site http://gregmaxey.mvps.org for an eclectic collection of Word Tips. Arrogance is a weed that grows mostly on a dunghill (Arabic proverb) |
#5
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Sort without "the" or "a"
On Wed, 4 Nov 2009 19:51:10 -0500, "Greg Maxey"
wrote: Second option very neat. Learn something new everyday. You can also do that with nails and hammers ;-) Sub ScratchMacoII() Dim oRng As Word.Range Dim oPar As Paragraph Dim oRngProcess Dim pStr As String Set oRng = Selection.Range For Each oPar In oRng.Paragraphs Select Case oPar.Range.Words.First Case "The ", "A " oPar.Range.Words.First.Font.Hidden = True oPar.Range.Shading.BackgroundPatternColorIndex = wdBrightGreen End Select Next Selection.Sort For Each oPar In oRng.Paragraphs Select Case oPar.Range.Shading.BackgroundPatternColorIndex Case wdBrightGreen oPar.Range.Words.First.Font.Hidden = False oPar.Range.Shading.BackgroundPatternColorIndex = wdAuto End Select Next End Sub ***Assumes of course that no paragraphs shading is used in the original text. Nifty macro. I suggest adding "An " to the Case list however... -- Bob http://www.kanyak.com |
#6
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Sort without "the" or "a"
Good point. Also, and Ms. Barnhill did say hide them, it might help to
ensure that hidden text is not displayed during the process: Sub ScratchMacoII() Dim bCurrentState 'Of hidden text display option Dim oRng As Word.Range Dim oPar As Paragraph Dim oRngProcess Dim pStr As String Set oRng = Selection.Range For Each oPar In oRng.Paragraphs Select Case oPar.Range.Words.First Case "The ", "A ", "An " oPar.Range.Words.First.Font.Hidden = True oPar.Range.Shading.BackgroundPatternColorIndex = wdBrightGreen End Select Next bCurrentState = ActiveWindow.View.ShowHiddenText ActiveWindow.View.ShowHiddenText = False Selection.Sort ActiveWindow.View.ShowHiddenText = bCurrentState For Each oPar In oRng.Paragraphs Select Case oPar.Range.Shading.BackgroundPatternColorIndex Case wdBrightGreen oPar.Range.Words.First.Font.Hidden = False oPar.Range.Shading.BackgroundPatternColorIndex = wdAuto End Select Next End Sub -- Greg Maxey See my web site http://gregmaxey.mvps.org for an eclectic collection of Word Tips. Arrogance is a weed that grows mostly on a dunghill (Arabic proverb) "Opinicus" wrote in message ... On Wed, 4 Nov 2009 19:51:10 -0500, "Greg Maxey" wrote: Second option very neat. Learn something new everyday. You can also do that with nails and hammers ;-) Sub ScratchMacoII() Dim oRng As Word.Range Dim oPar As Paragraph Dim oRngProcess Dim pStr As String Set oRng = Selection.Range For Each oPar In oRng.Paragraphs Select Case oPar.Range.Words.First Case "The ", "A " oPar.Range.Words.First.Font.Hidden = True oPar.Range.Shading.BackgroundPatternColorIndex = wdBrightGreen End Select Next Selection.Sort For Each oPar In oRng.Paragraphs Select Case oPar.Range.Shading.BackgroundPatternColorIndex Case wdBrightGreen oPar.Range.Words.First.Font.Hidden = False oPar.Range.Shading.BackgroundPatternColorIndex = wdAuto End Select Next End Sub ***Assumes of course that no paragraphs shading is used in the original text. Nifty macro. I suggest adding "An " to the Case list however... -- Bob http://www.kanyak.com |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
email merge with multiple recipients in "To", "CC" & "BCC" | Mailmerge | |||
cannot type "@" and "^" and "#" in word (ms office 2007) | Microsoft Word Help | |||
I can't "Open" a downloaded template. Only "Save" and "Cancel" | Microsoft Word Help | |||
What does "char" "char1" "char2" mean in styles in Word? | Microsoft Word Help | |||
The "Symbol" under "Insert" disappeared and replaced by "Number" | Microsoft Word Help |