Get to print the files to printer

J

john

Is there a funtion out there that will print MyFileList for me?

Private Sub Command1_Click()
On Error GoTo Err_Command1_Click

Command1.Caption = "Print"
Dim FileName As String
FileName = Dir("C:\VariousPrintableFileTypes\*.*")
Do While Len(FileName)
myFileList = myFileList & FileName & vbNewLine
FileName = Dir()

Debug.Print myFileList
Loop

Exit_Command1_Click:
Exit Sub

Err_Command1_Click:
MsgBox Err.Description
Resume Exit_Command1_Click

End Sub

Thanks John
 
G

Guest

You'll need to do this from within an existing report.

' This code comes from Access help under the topic "Print Method"
Private Sub Detail_Format(Cancel As Integer, _
FormatCount As Integer)
Dim rpt as Report
Dim strMessage As String
Dim intHorSize As Integer, intVerSize As Integer

Set rpt = Me
strMessage = GetFiles
With rpt
'Set scale to pixels, and set FontName and
'FontSize properties.
.ScaleMode = 3
.FontName = "Courier"
.FontSize = 24
End With
' Horizontal width.
intHorSize = Rpt.TextWidth(strMessage)
' Vertical height.
intVerSize = Rpt.TextHeight(strMessage)
' Calculate location of text to be displayed.
Rpt.CurrentX = (Rpt.ScaleWidth/2) - (intHorSize/2)
Rpt.CurrentY = (Rpt.ScaleHeight/2) - (intVerSize/2)
' Print text on Report object.
Rpt.Print strMessage
End Sub

Private Function GetFiles()
Dim FileName As String
FileName = Dir("C:\VariousPrintableFileTypes\*.*")
Do While Len(FileName)
myFileList = myFileList & FileName & vbNewLine
FileName = Dir()

' Debug.Print myFileList
Loop
GetFiles = myFileList
End Function


Barry
 

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