[AccessD] Batch printing the .doc files from a folder

Ervin Brindza viner at eunet.yu
Wed Jul 14 00:53:37 CDT 2004


Max,
It's perfect!!! Many thanks for the code. I need it for Access97 too(forgot
to mention), but you helped me a lot!
Have a nice day,
    Ervin

----- Original Message -----
From: <mgauk at btconnect.com>
To: "'Access Developers discussion and problem solving'"
<accessd at databaseadvisors.com>
Sent: 13 July, 2004 5:25 PM
Subject: RE: [AccessD] Batch printing the .doc files from a folder


> Try This: Create a Button on a form call ButPrintAllDocFiles and put this
> code behind the form
>
> Option Compare Database
> Option Explicit
>
> Private Sub ButPrintWordDocs_Click()
>   Call fPrintAllDocFiles
> End Sub
> Private Function fPrintAllDocFiles()
>   ' FileDialog require a Reference to Microsoft Office 11 Object Library
>   ' and we also need a reference to Microsoft Word 11 Object Library
>   ' in HELP, search under 'system' in the index
>   Dim fs, f, f1, fc, sDocs, folderspec As String, iResponse As Integer
>   Dim sFN As String
>   Dim objWord As Word.Application
>   Set fs = CreateObject("Scripting.FileSystemObject")
>   Set objWord = New Word.Application
>   folderspec = pfGetSingleFolder("C:\")
>   If Len(folderspec) = 0 Then GoTo exithere
>   Set f = fs.GetFolder(folderspec)
>   Set fc = f.Files
>   For Each f1 In fc
>     If Right(f1.Name, 4) = ".doc" And Not Left(f1.Name, 1) = "~" Then
>       sFN = folderspec & "\" & f1.Name
>       ' comment out the next 2 lines for autoprinting and the
corresponding
> 'End If'
>       iResponse = MsgBox("Print This File:-" & vbCrLf & vbCrLf & sFN,
> vbYesNo + vbQuestion, "Print All")
>       If iResponse = vbYes Then
>         objWord.Documents.Add Template:=sFN, NewTemplate:=False
>         objWord.Options.PrintBackground = True
>         objWord.ActiveDocument.PrintOut
>         objWord.ActiveDocument.Close
>       End If
>     End If
>   Next
> exithere:
>   Set objWord = Nothing
>   MsgBox "Finished"
> Exit Function
> End Function
> Public Function pfGetSingleFolder(Optional strStartFolder As String) As
> Variant
>     ' FileDialog require a Reference to Microsoft Office 11 Object Library
>     On Error GoTo errhandler
>     Dim fd As FileDialog
>     Set fd = FileDialog(msoFileDialogFolderPicker)
>     fd.AllowMultiSelect = False
>     fd.Title = "Select a Folder to Auto-Print ALL Word documents in that
> Folder"
>     fd.ButtonName = "Select Folder"
>     fd.InitialFileName = strStartFolder
>     fd.Show
>     pfGetSingleFolder = fd.SelectedItems.Item(1) ' only 1 allowed
>     'MsgBox pfGetSingleFolder
> exithere:
>     Set fd = Nothing
>     Exit Function
> errhandler:
>     Select Case Err.Number
>     Case 5 ' user cancelled
>     pfGetSingleFolder = ""
>     Case Else
>     MsgBox Err.Number & vbCrLf & Err.Description
>     End Select
>     Resume exithere
> End Function
>
> Max Sherman
>
>
> -----Original Message-----
> From: accessd-bounces at databaseadvisors.com
> [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Ervin Brindza
> Sent: 13 July 2004 13:08
> To: Access Developers discussion and problem solving
> Subject: Re: [AccessD] Batch printing the .doc files from a folder
>
> Mark,
> many thanks for the suggestion, but my customer want a single button push
> :-( Ervin
> ----- Original Message -----
> From: "Mitsules, Mark S. (Newport News)" <Mark.Mitsules at ngc.com>
> To: "'Access Developers discussion and problem solving'"
> <accessd at databaseadvisors.com>
> Sent: 13 July, 2004 2:02 PM
> Subject: RE: [AccessD] Batch printing the .doc files from a folder
>
>
> > Ervin,
> >
> > The quickest, simplest way I know of is to highlight them all,
> right-click,
> > and choose print.  They will each open, print, and close automatically.
> >
> >
> > Mark
> >
> >
> > -----Original Message-----
> > From: Ervin Brindza [mailto:viner at eunet.yu]
> > Sent: Tuesday, July 13, 2004 4:47 AM
> > To: AccessD at databaseadvisors.com
> > Subject: [AccessD] Batch printing the .doc files from a folder
> >
> >
> > Hi,
> > there are a plenty of .doc files in a particular folder, and I want to
> print
> > them without manually opening every single file. I'm interested in VBA
> > or .bat or whatever solution!
> > Many TIA's
> >     Ervin
> > --
> > _______________________________________________
> > AccessD mailing list
> > AccessD at databaseadvisors.com
> > http://databaseadvisors.com/mailman/listinfo/accessd
> > Website: http://www.databaseadvisors.com
> > --
> > _______________________________________________
> > AccessD mailing list
> > AccessD at databaseadvisors.com
> > http://databaseadvisors.com/mailman/listinfo/accessd
> > Website: http://www.databaseadvisors.com
>
>
> --
> _______________________________________________
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>
> ---
> Incoming mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.719 / Virus Database: 475 - Release Date: 12/07/2004
>
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.719 / Virus Database: 475 - Release Date: 12/07/2004
>
>
> --
> _______________________________________________
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com





More information about the AccessD mailing list