Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
sorting by last name
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: Thank you, DReece |
#2
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
sorting by last name
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 -- 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 "CMDS" wrote in message ... 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: Thank you, DReece |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Need option to ignore quotation marks in sorting bibliography. | Microsoft Word Help | |||
Sorting dates | Tables | |||
Sorting by Dates | Microsoft Word Help | |||
sorting alphanumerically in a table | Microsoft Word Help | |||
Sorting a table while keeping some related rows together | Tables |