1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Printing Multiple files from a folder

Discussion in 'Business Applications' started by eathen, Jul 24, 2006.

Thread Status:
Not open for further replies.
Advertisement
  1. eathen

    eathen Thread Starter

    Joined:
    Jul 24, 2006
    Messages:
    16
    I would like to know how to print multiple files in a folder. For example, a folder contains 50 Ms Word documents that needs to be printed. I do not want to open each document to print. The driver I have for HP laserjet 4300tn is updated. Is there a batch file that needs to be created? Is there a solution to this issue? Or is there a workaround?

    Tested the following attempts, nothing gets printed
    I tried selecting all the document, right click>print.
    Selected all the document, then dragged them onto the printer icon.
    Copied the printer icon into the "send to" option, then selected all the document and selected send to> printer_name.
     
  2. StumpedTechy

    StumpedTechy

    Joined:
    Jul 7, 2004
    Messages:
    7,232
  3. eathen

    eathen Thread Starter

    Joined:
    Jul 24, 2006
    Messages:
    16
    Even after deleting the printer and reinstalling it from scrath does not help. The printer is networked in our office, does this have an effect?
     
  4. kenneth2k1

    kenneth2k1

    Joined:
    Oct 9, 2003
    Messages:
    252
    One guess I have is to check the amount of installed RAM. If the size of the print job exceeds the amount of RAM the printer has, it may drop the jobs all together. Also, try only selecting 5 or so files to print and see if they go through.
     
  5. Squashman

    Squashman Trusted Advisor

    Joined:
    Apr 4, 2003
    Messages:
    19,731
    Funny you should mention this, we are experiencing the same problem on one of the PC's here at work. The user is trying to print about 40 single page text files and it will only print about three of them everytime we try selecting them all and right clicking to print. I have always done that method in the past but it doesn't seem to be working on her pc which is Windows 2000 SP4
     
  6. kenneth2k1

    kenneth2k1

    Joined:
    Oct 9, 2003
    Messages:
    252
    I had a similar problem once, and the job wasn't spooling properly. It would get to a certain size and stop building the print job. Then the job never went through. What solved it was installing a network print monitor (it came with the printer's software) and that made the jobs go through for some reason. That was on 2k SP4 printing to a Canon imageclass.
     
  7. eathen

    eathen Thread Starter

    Joined:
    Jul 24, 2006
    Messages:
    16
    I am pretty sure the printer has enough ram to carry out the request. I believe the printer has 256 MB ram.
    I have tried printing 15, 10, 5, 2 files at a time, I don’t even see the printer icon that come up in the system tray and the printer status is Ready.
    It only prints single pages at a time.
    Do guys think there is free third party software that will perform this function?
    At our office we are running winxp pro sp2
     
  8. Rollin_Again

    Rollin_Again

    Joined:
    Sep 4, 2003
    Messages:
    4,732
    You can use a VBA script or macro to do this. Does the directory containing the word files contain any other file types?

    Put the following code into a notepad file and rename the file extension to .VBS
    Make sure to change the file path to the path of your actual directory. Then save the VBS file and double click to execute.

    Code:
    set shApp = createobject("shell.application") 
    set shFolder = shApp.namespace("C:\TEST") 
    set shItems = shFolder.Items() 
    for each shItem in shItems 
      shItem.invokeverb "&Print" 
    next 
    Rollin
     
  9. eathen

    eathen Thread Starter

    Joined:
    Jul 24, 2006
    Messages:
    16
    Thank you all for your help.
    Rollin_Again nailed my question. Thanks a lot.
    The folder only contained Ms Word documents. I have not tested with other file formats. How would you create a Macro for this issue?
    Thank you once again.
     
  10. Rollin_Again

    Rollin_Again

    Joined:
    Sep 4, 2003
    Messages:
    4,732
    The instructions for creating the stand-alone VB Script are in my post above. If you would rather have the code executed directly out of word let me know and I'll write the code for you.

    Rollin
     
  11. eathen

    eathen Thread Starter

    Joined:
    Jul 24, 2006
    Messages:
    16
    You have resolved my issue.
    But for reference in the future, I would not mind having the code execute directly out of Word.
     
  12. Rollin_Again

    Rollin_Again

    Joined:
    Sep 4, 2003
    Messages:
    4,732
    Sorry it took so long to get back. I've attached a word document with the macro already attached. Just open the word document and run the macro called "PrintAll" This will pop up an explorer style window that will allow you to click the directory that want to print the contents of. The code currently assumes that the directory only contains word documents. It can be easily modified to include logic to ignore any files that are not word documents.

    Copy and paste the following code into a blank module in Word and then run the macro called "PrintAll"

    Code:
    'API Declares
    Private Declare Function SendMessage Lib "USER32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    Private Declare Function SHBrowseForFolder Lib "shell32.dll" Alias "SHBrowseForFolderA" (lpbi As BrowseInfo) As Long
    Private Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long
    Private Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal hMem As Long)
    
    'API Constants
    Private Const MAX_PATH = 260
    Private Const BIF_RETURNONLYFSDIRS = 1
    Private Const BIF_STATUSTEXT = 4
    
    Private Const WM_USER = &H400
    Private Const BFFM_INITIALIZED = 1
    Private Const BFFM_SELCHANGED = 2
    Private Const BFFM_SETSTATUSTEXTA = (WM_USER + 100)
    
    Private Const BFFM_SETSELECTIONA = (WM_USER + 102)
    
    
    'BrowseInfo Type
    Private Type BrowseInfo
        hwndOwner As Long
        pIDLRoot As Long
        pszDisplayName As String
        lpszTitle As String
        ulFlags As Long
        lpfn As Long
        lParam As Long
        iImage As Long
    End Type
    
    'Private Variables
    Private m_sDefaultFolder As String
    Public Sub BrowseFolder()
    
    frmBrowse.Show
    frmBrowse.txtDirectory.Text = ""
    
    
    End Sub
    
    Public Function BrowseForFolder(DefaultFolder As String, Optional Parent As Long = 0, Optional Caption As String = "") As String
        Dim bi As BrowseInfo
        Dim sResult As String, nResult As Long
    
        bi.hwndOwner = Parent
        bi.pIDLRoot = 0
        bi.pszDisplayName = String$(MAX_PATH, Chr$(0))
        If Len(Caption) > 0 Then
            bi.lpszTitle = Caption
        End If
        bi.ulFlags = BIF_RETURNONLYFSDIRS
        bi.lpfn = GetAddress(AddressOf BrowseCallbackProc)
        bi.lParam = 0
        bi.iImage = 0
    
        m_sDefaultFolder = DefaultFolder
    
        nResult = SHBrowseForFolder(bi)
    
        If nResult <> 0 Then
            sResult = String(MAX_PATH, 0)
            If SHGetPathFromIDList(nResult, sResult) Then
                BrowseForFolder = Left$(sResult, InStr(sResult, Chr$(0)) - 1)
            End If
    
            CoTaskMemFree nResult
        End If
    End Function
    
    
    Private Function BrowseCallbackProc(ByVal hwnd As Long, ByVal uMsg As Long, ByVal lParam As Long, ByVal lpData As Long) As Long
        Select Case uMsg
            Case BFFM_INITIALIZED
    
                If Len(m_sDefaultFolder) > 0 Then
    
                    SendMessage hwnd, BFFM_SETSELECTIONA, True, ByVal m_sDefaultFolder
                End If
        End Select
    End Function
    
    
    Private Function GetAddress(nAddress As Long) As Long
        GetAddress = nAddress
    End Function
    
    Public Sub PrintAll()
    
    Dim txtDirectory As String
    
    txtDirectory = BrowseForFolder(txtDirectory, , "&Select a directory:")
    
    
    With Application.FileSearch
    .NewSearch
    .LookIn = txtDirectory
    .SearchSubFolders = False
    .FileType = msoFileTypeWordDocuments
    If .Execute() > 0 Then
    For i = 1 To .FoundFiles.Count
    Application.PrintOut , , , , , , , , , , , , CStr(.FoundFiles(i))
    Next i
    End If
    End With
    
    End Sub
    Regards,
    Rollin
     

    Attached Files:

  13. eathen

    eathen Thread Starter

    Joined:
    Jul 24, 2006
    Messages:
    16
    Thank you again Rollin_Again for you input for my thread.
     
  14. Rollin_Again

    Rollin_Again

    Joined:
    Sep 4, 2003
    Messages:
    4,732
    Glad to help!! Did you download the zip file I attached to my last post? It is a sample word document that does exactly what you want and you can just click on the folder you want to print from.

    Rollin
     
  15. peglar

    peglar

    Joined:
    Apr 18, 2007
    Messages:
    6
    I have tried your word doc macro and it almost does exactly what i require, however i am trying to do this with html files and although it prints them word is formatting them to have odd spacing etc.

    would it be possible to do this as a standalone .exe?

    my knowledge of VB is appaling at best.
     
  16. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/485943