WordBasic.SortArray FileArray

J

Joanne Buss

Hello group
I have a macro I use to open word docs in batches. I need them to open up
sorted by name. The directory they are coming from is sorted by name - makes
for easy sync if they open in word the same way. This macro I am posting
used to do the sorting for me and I got everything nicely alpabetized. But
right now it isn't working for me - the files are coming in some random
order that is very inconvenient to my purposes.
Can anyone spot what the problem is and point it out to me please.
I am running MSWord 2003 SP3 on XP Pro SP3 on Dell OptiPlex GX270
Thanks for your help in advance
Joanne


Public Sub GetFiles()
' GetFiles Macro
' Macro recorded 06/23/00 by Joanne
'
'Application.CommandBars("Main Menu").Visible = False
Dim Resumes As String, FileArray() As String, Num As Long, OpnFile As Long
Dim PassNum As Integer, temp As String 'sorting variables
Dim Upper As Long 'Upper boundary of array
ReDim FileArray(700)
Num = 0 'Setting counter to 0
OpnFile = 0 'Setting counter to 0

Resumes = Dir$("C:\Resumes-ToDo\todo\*.*") 'Where the files are at
Do While Len(Resumes) > 0 ' Loop to put files into an array
FileArray(Num) = Resumes
Num = Num + 1
Resumes = Dir$
Loop
ReDim Preserve FileArray(Num - 1)
Upper = UBound(FileArray)

' Sort array
WordBasic.SortArray FileArray


' Open the files for editing
For OpnFile = 0 To 19
If OpnFile <= Upper Then 'if there are files in the array
Documents.Open FileName:="C:\Resumes-ToDo\todo\" _
& FileArray(OpnFile) 'then open the next one and increment counter
' Application.ShowWindowsInTaskbar = True
'Application.WindowState = wdWindowStateNormal
ActiveWindow.ActivePane.View.Zoom.Percentage = 118

End If
If OpnFile = -1 Then
Application.Quit
End If
Next

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top