Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
lilac lilac is offline
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
Suzanne S. Barnhill Suzanne S. Barnhill is offline
external usenet poster
 
Posts: 33,624
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
Greg Maxey[_2_] Greg Maxey[_2_] is offline
external usenet poster
 
Posts: 668
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
Greg Maxey[_2_] Greg Maxey[_2_] is offline
external usenet poster
 
Posts: 668
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
Opinicus[_2_] Opinicus[_2_] is offline
external usenet poster
 
Posts: 97
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
Greg Maxey[_2_] Greg Maxey[_2_] is offline
external usenet poster
 
Posts: 668
Default 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

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
email merge with multiple recipients in "To", "CC" & "BCC" Raghu Mailmerge 6 April 21st 23 12:58 PM
cannot type "@" and "^" and "#" in word (ms office 2007) Petero Microsoft Word Help 1 February 1st 09 08:26 PM
I can't "Open" a downloaded template. Only "Save" and "Cancel" Dave Microsoft Word Help 1 April 4th 08 02:28 PM
What does "char" "char1" "char2" mean in styles in Word? Li Microsoft Word Help 2 September 5th 07 03:22 PM
The "Symbol" under "Insert" disappeared and replaced by "Number" Eling Microsoft Word Help 3 September 13th 06 03:29 PM


All times are GMT +1. The time now is 12:18 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"