J
jlawson
I work for a non-profit hospital and I've developed a MS Word form for
the nurses to use for notifying the Scheduling department when the
scheduling department is closed. All the forms are saved to a certain
folder Scheduling can get to.
What I wanted to make was a separate document for the Manager for that
department to print all the forms in that folder by a date range.
I've found a macro on a help site (I don't remember the name) that
will allow the manager to print all the documents in a folder and
modified it.
The format the form saves in is: MM-DD-YYYY Doe,John 99999 the 99999 is
a unique identifier for that particular patient visit. I can create a
Userform for the manager where she can type in the date range she
wants. I was thinking of using the date form saved in the folder which
is the date modified.
This is the macro, so far, for printing everything in the folder:
Private Sub BatchFilePrint_Click()
Dim fs, f, fc, f1
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder("S:\After Hours Scheduling\Requests")
Set fc = f.Files
Dim FileList() As String
Dim Cnt As Integer
Cnt = 0
Dim myDoc As Word.Document
For Each f1 In fc
Dim WithoutExt As String
WithoutExt = LCase(Right(f1.Name, 4))
Dim FileName As String
FileName = Left(f1.Name, Len(f1.Name) - 4)
If WithoutExt = LCase(".doc") Then
WordBasic.DisableAutoMacros 1
Application.Documents.Open FileName:=f & "\" & f1.Name,
Visible:=False
Set myDoc = Application.Documents(f & "\" & f1.Name)
myDoc.PrintOut
myDoc.Close savechanges:=False
Set myDoc = Nothing
WithoutExt = ""
FileName = ""
WordBasic.DisableAutoMacros 0
End If
Next
End Sub
We are using MS Office XP here. Thank you in advance!
the nurses to use for notifying the Scheduling department when the
scheduling department is closed. All the forms are saved to a certain
folder Scheduling can get to.
What I wanted to make was a separate document for the Manager for that
department to print all the forms in that folder by a date range.
I've found a macro on a help site (I don't remember the name) that
will allow the manager to print all the documents in a folder and
modified it.
The format the form saves in is: MM-DD-YYYY Doe,John 99999 the 99999 is
a unique identifier for that particular patient visit. I can create a
Userform for the manager where she can type in the date range she
wants. I was thinking of using the date form saved in the folder which
is the date modified.
This is the macro, so far, for printing everything in the folder:
Private Sub BatchFilePrint_Click()
Dim fs, f, fc, f1
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder("S:\After Hours Scheduling\Requests")
Set fc = f.Files
Dim FileList() As String
Dim Cnt As Integer
Cnt = 0
Dim myDoc As Word.Document
For Each f1 In fc
Dim WithoutExt As String
WithoutExt = LCase(Right(f1.Name, 4))
Dim FileName As String
FileName = Left(f1.Name, Len(f1.Name) - 4)
If WithoutExt = LCase(".doc") Then
WordBasic.DisableAutoMacros 1
Application.Documents.Open FileName:=f & "\" & f1.Name,
Visible:=False
Set myDoc = Application.Documents(f & "\" & f1.Name)
myDoc.PrintOut
myDoc.Close savechanges:=False
Set myDoc = Nothing
WithoutExt = ""
FileName = ""
WordBasic.DisableAutoMacros 0
End If
Next
End Sub
We are using MS Office XP here. Thank you in advance!