Printing documents in alphabetical order 
Author Message
 Printing documents in alphabetical order

Hi All

I have written a small macro to print the entire contents of a folder.  The
only problem being that the documents print in an order which closely
resembles timestamp order, but not really!  What I would really like is to
print the documents in alphabetical order.  The macro goes as follows, any
ideas would be appreciated.

Sub PrintCPManual()
'
' PrintCPManual Macro
' Print entire Clinical Procedures Manual
'
numcopies = InputBox("Enter number of copies to print:", "Number of Copies")
If numcopies = "" Then GoTo EndMsg

msgResult = MsgBox("You will be promted with the Open dialog box.  Please
open the Cover of your Clinical Procedures Manual.  By default, the manual
is stored in C:\My Documents\CP Manual, unless altered during
installation.", vbOKCancel, "Instructions")
If msgResult = 2 Then GoTo EndMsg

dlgResult = Dialogs(wdDialogFileOpen).Show
If dlgResult = 0 Then GoTo EndMsg

adoc = Dir("*.DOC")
While adoc <> ""
    Application.PrintOut FileName:=adoc, copies:=numcopies
    adoc = Dir()
Wend
GoTo EndMacro
EndMsg:
MsgBox ("Printing Aborted")
EndMacro:
End Sub

Thanks
Rachel



Fri, 29 Jul 2005 08:58:03 GMT  
 Printing documents in alphabetical order
Result from Hitting F1 on Dir, the following tip comes up:
Tip   Because file names are retrieved in no particular order, you may want
to store returned file names in an array, and then sort the array.


Quote:
> Hi All

> I have written a small macro to print the entire contents of a folder.
The
> only problem being that the documents print in an order which closely
> resembles timestamp order, but not really!  What I would really like is to
> print the documents in alphabetical order.  The macro goes as follows, any
> ideas would be appreciated.

> Sub PrintCPManual()
> '
> ' PrintCPManual Macro
> ' Print entire Clinical Procedures Manual
> '
> numcopies = InputBox("Enter number of copies to print:", "Number of
Copies")
> If numcopies = "" Then GoTo EndMsg

> msgResult = MsgBox("You will be promted with the Open dialog box.  Please
> open the Cover of your Clinical Procedures Manual.  By default, the manual
> is stored in C:\My Documents\CP Manual, unless altered during
> installation.", vbOKCancel, "Instructions")
> If msgResult = 2 Then GoTo EndMsg

> dlgResult = Dialogs(wdDialogFileOpen).Show
> If dlgResult = 0 Then GoTo EndMsg

> adoc = Dir("*.DOC")
> While adoc <> ""
>     Application.PrintOut FileName:=adoc, copies:=numcopies
>     adoc = Dir()
> Wend
> GoTo EndMacro
> EndMsg:
> MsgBox ("Printing Aborted")
> EndMacro:
> End Sub

> Thanks
> Rachel




Fri, 29 Jul 2005 11:27:05 GMT  
 Printing documents in alphabetical order
Hi Rae,

You might also want to investigate using the FileSystemObject. Here's an
example from the VBA help file:

    Dim fs, f, f1, fc, s
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set f = fs.GetFolder("C:\")
    Set fc = f.Files
    For Each f1 In fc
        s = s & f1.Name
        s = s & vbCrLf
    Next
    MsgBox s

HTH

Quote:
> Hi All

> I have written a small macro to print the entire contents of a folder.
The
> only problem being that the documents print in an order which closely
> resembles timestamp order, but not really!  What I would really like is to
> print the documents in alphabetical order.  The macro goes as follows, any
> ideas would be appreciated.

> Sub PrintCPManual()
> '
> ' PrintCPManual Macro
> ' Print entire Clinical Procedures Manual
> '
> numcopies = InputBox("Enter number of copies to print:", "Number of
Copies")
> If numcopies = "" Then GoTo EndMsg

> msgResult = MsgBox("You will be promted with the Open dialog box.  Please
> open the Cover of your Clinical Procedures Manual.  By default, the manual
> is stored in C:\My Documents\CP Manual, unless altered during
> installation.", vbOKCancel, "Instructions")
> If msgResult = 2 Then GoTo EndMsg

> dlgResult = Dialogs(wdDialogFileOpen).Show
> If dlgResult = 0 Then GoTo EndMsg

> adoc = Dir("*.DOC")
> While adoc <> ""
>     Application.PrintOut FileName:=adoc, copies:=numcopies
>     adoc = Dir()
> Wend
> GoTo EndMacro
> EndMsg:
> MsgBox ("Printing Aborted")
> EndMacro:
> End Sub

> Thanks
> Rachel




Fri, 29 Jul 2005 22:23:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Print documents in alphabetical order

2. Print documents in alphabetical order

3. to cross a table in alphabetical order

4. Automatic alphabetical order

5. Alphabetical order

6. Help, dir : how to class files by alphabetical order

7. DBCombo to show fields in alphabetical order

8. sorting array values in alphabetical order

9. listbox alphabetical order

10. Alphabetical Order

11. Alphabetical order

12. Sort strings in alphabetical order

 

 
Powered by phpBB® Forum Software