Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Mailmerge and Fax / December 2005

Tip: Looking for answers? Try searching our database.

sorting by last name

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
CMDS - 10 Dec 2005 13:11 GMT
I have 150 pages in Word that I would like to sort based on client LAST NAME,
FIRST NAME.  Each page contains the client name and page of text specifcally
about the client which will need to be kept with the name during the alpha
sort.  How would I put in a field for LAST NAME, FIRST NAME and have WORD put
each page in order based on alpha order of the client name?  The page of text
notes needs to be intact during this sort.  I am not sure how to capture the
text on each page so that it includes the client's name where I can later
sort or how to enter a field for client LAST NAME so the I can perform the
sort in Ascending order.  Any ideas?  Please reply to: cmds@charter.net

Thank you,

DReece
Doug Robbins - Word MVP - 10 Dec 2005 16:25 GMT
Exactly where on the page is the name?

I think that what you will need to do is save each page of the document as a
separate file in a directory that you create for the purpose with the name
of the file being the LastNameFirstName and then use a macro to recombine
the individual files into a new document by order of the filename.  A
modification of the following macro could do the splitting:

Sub splitter()

'

' splitter Macro

' Macro created 16-08-98 by Doug Robbins to save each page of a document

' as a separate file with the name Page#.DOC

'

Dim Counter As Long, Source As Document, Target As Document

Set Source = ActiveDocument

Selection.HomeKey Unit:=wdStory

Pages = Source.BuiltInDocumentProperties(wdPropertyPages)

Counter = 0

While Counter < Pages

   Counter = Counter + 1

   DocName = "Page" & Format(Counter)

   Source.Bookmarks("\Page").Range.Cut

   Set Target = Documents.Add

   Target.Range.Paste

   Target.SaveAs FileName:=DocName

   Target.Close

Wend

End Sub

Then, the following macro should recombine the documents:

Dim MyPath As String
Dim MyName As String
Dim Source As Document
Dim Target As Document

'let user select a path
With Dialogs(wdDialogCopyFile)
   If .Display() <> -1 Then Exit Sub
   MyPath = .Directory
End With

'strip quotation marks from path

If Len(MyPath) = 0 Then Exit Sub

If Asc(MyPath) = 34 Then
   MyPath = Mid$(MyPath, 2, Len(MyPath) - 2)
End If

'get files from the selected path
'and insert them into the doc
MyName = Dir$(MyPath & "*.*")
Set Target = Documents.Add
Do While MyName <> ""
   Set Source = Documents.Open(MyName)
   Target.Range.InsertAfter Source.Range.FormattedText
   Source.Close wdDoNotSaveChanges
   MyName = Dir
Loop

Signature

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

>I have 150 pages in Word that I would like to sort based on client LAST
>NAME,
[quoted text clipped - 14 lines]
>
> DReece
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.