+ Reply to Thread
Results 1 to 5 of 5

VBA for batch printing from Outlook

  1. #1
    Registered User
    Join Date
    12-25-2013
    Location
    Norwich
    MS-Off Ver
    2003
    Posts
    5

    VBA for batch printing from Outlook

    Hi everyone,

    I have limited knowledge in VBA programming, but used to learn PHP and Java in past, so might understand a logic of simple scripts.

    I have hundreds of emails coming with(e.g.) Subject "Payslip" and From "Payroll". All those emails contain PDF file "Payslip.pdf" and information in each file is unique.

    There is a rule in Outlook to move all those emails to folder "Payslips AutoPrint"

    I found online macro for batch printing and adjusted it for my needs:

    Please Login or Register  to view this content.
    Now to the problem - because my pdf files all have the same name ("Payslip.pdf") this script doesn't work for my situation.

    It would be nice to have those files saved to "C:\TempPayslips\" in following format "001-Payslip.pdf .... XXX-Payslip.pdf" with 001 being incremented each time by 1 and in an ideal world script needs to make sure that it doesn't assign any of the existing names to the file (e.g. 025-Payslip.pdf is already exist and next saved would be 026-Payslip.pdf)

    Now let's say that it printed successfully all 300 payslips and moved all emails to "PrintedPayslips", if there is a way to empty this folder(PrintedPayslips) and delete all content of C:\TempPaySlips\ when macro is done with printing them all?

    Any help very appreciated.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: VBA for batch printing from Outlook

    If you're deleting the files after printing, then;
    1.) no need to save a temporary file. You could print the attachments directly.
    2.) delete each mail item after the attachment has been printed.

    Try something like this (not tested):

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    12-25-2013
    Location
    Norwich
    MS-Off Ver
    2003
    Posts
    5

    Re: VBA for batch printing from Outlook

    Hi AlphaFrog,

    Thanks for your reply.

    I didn't realize that it's not necessary to save attachment in order to print it and this step was described as important on the website I took it from.

    I really hope it will work, but I won't be able to test until next year. Will come back with results as soon as possible.

    Once again thanks for help

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: VBA for batch printing from Outlook

    You're welcome.

    Quote Originally Posted by afonja View Post
    I didn't realize that it's not necessary to save attachment in order to print it and this step was described as important on the website I took it from.
    Maybe it is important. Outlook can be quirky to work with sometimes and I'm not an expert with it. Give it a try anyway. Then we'll both know.

  5. #5
    Registered User
    Join Date
    12-25-2013
    Location
    Norwich
    MS-Off Ver
    2003
    Posts
    5

    Re: VBA for batch printing from Outlook

    Run-time error '438':
    Object doesn't support this property or method

    FileName = Atmt.PathName & Application.PathSeparator & Atmt.FileName

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. VBA for batch printing from Outlook
    By afonja in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-25-2013, 01:04 PM
  2. Batch Workbook Printing for selected
    By Ryeno24 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-13-2006, 05:28 AM
  3. [SOLVED] batch printing without VBA
    By krikri in forum Excel General
    Replies: 2
    Last Post: 02-09-2006, 10:30 AM
  4. [SOLVED] Batch printing of excel files
    By Grd in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-20-2005, 03:05 PM
  5. [SOLVED] Batch printing without prompts
    By John Smith in forum Excel General
    Replies: 2
    Last Post: 07-16-2005, 06:05 AM

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