+ Reply to Thread
Results 1 to 4 of 4

Code to print all files in a folder (to default printer)

  1. #1
    Forum Contributor
    Join Date
    07-09-2008
    Location
    Dallas
    MS-Off Ver
    2007
    Posts
    121

    Code to print all files in a folder (to default printer)

    Searched, didn't find this here, so...

    I need Excel macro code that will print all files in a folder in a specified path (will be all pdf's, but if flexible to simply print them all no matter what extension they may be, that'd be great).

    I don't need (don't want) to open the files, just simply dump every file in a folder on the network to the default printer as though they had individually been opened and printed one at a time.

    Found and tried the following at MS but it fails (old unsupported version, it seems):

    Sub PrintDocsInFolder()
    Dim sMyDir As String
    Dim sDocName As String

    ' The path to obtain the files.
    sMyDir = "C:\Sales Summary\Print\"
    sDocName = Dir(sMyDir & "*.pdf")

    While sDocName <> ""
    ' Print the file.
    Application.PrintOut Filename:=sDocName
    ' Get next file name.
    sDocName = Dir()
    Wend
    End Sub
    It fails on the 'application.printout' line - "Object doesn't support this property or method".

    Help?

    Thanks!
    Last edited by jwhitwell; 01-22-2010 at 03:56 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Code to print all files in a folder (to default printer)

    Hello jwhitwell,

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Contributor
    Join Date
    07-09-2008
    Location
    Dallas
    MS-Off Ver
    2007
    Posts
    121

    Re: Code to print all files in a folder (to default printer)

    Fixed, sorry.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Code to print all files in a folder (to default printer)

    Application.PrintOut is a method in Word, not Excel. Try running the macro in Word.
    Entia non sunt multiplicanda sine necessitate

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1