application.quit

J

Joanne Buss

Hello everyone
I have a little sub routine to put files from a specific folder into an
array, then open and process them 14 files at a time.
The following code does this just fine, except right at the end I want to
close the application (because it will not allow
me to delete all of the processed files - always gets stuck on the last
one!!), then I can delete ALL of the files that have
been processed, re-open Word and do the whole thingy again.
OpnFile is the counter for the for the open files and when I have done all
14, it should equal 0 and then close, but clearly
I have something wrong here.
Could you please help me to either close the app or force it to release the
last file so that I can delete all proceessed files?

Thanks a bunch for your help on this
Joanne

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(500)
Num = 0 'Setting counter to 0
OpnFile = 0 'Setting counter to 0

Resumes = Dir$("C:\Resumes-ToDo\ceweekly\*.*") '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 13
If OpnFile <= Upper Then 'if there are files in the array
Documents.Open FileName:="C:\Resumes-ToDo\ceweekly\" _
& FileArray(OpnFile) 'then open the next one and increment counter
ActiveWindow.ActivePane.View.Zoom.Percentage = 118
End If
Next
If OpnFile = 0 Then
Application.Quit
End If
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