View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Dallas Dallas is offline
external usenet poster
 
Posts: 20
Default Pause a loop after 100 cycles

I have a macro that cycles through each file in a folder and makes some
changes, prints, saves and then closes one at a time. Some of the folders I
need to run this code on have a very large number of files in them and the
printer will with out a doubt run out of paper before the folder is finished.
I would like to have the macro pause after 100 cycles so I can check the
printer for paper and click OK on a message box to continue. Here is the code
I am currently using. I would also like have the macro promt to select the
right folder with a browser box rather than an input box. I tried using
msoFileDialogFolderPicker without much success.

Thanks,
Dallas

Sub FixQIshtsInFolder()
Dim myPath As String
myPath = InputBox("Path?")
Dim fs, f, f1, fc
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(myPath)
Set fc = f.Files
For Each f1 In fc
If LCase(Right(Trim(f1.Name), 4)) = ".xls" Then
Workbooks.Open myPath & "\" & f1.Name
Application.Run "QIshtNoMsg" 'do whatever
End If
Next
MsgBox "Folder Done!"
End Sub