+ Reply to Thread
Results 1 to 16 of 16

Need help creating a macro that prints one or all employee payslips from payroll database

  1. #1
    Registered User
    Join Date
    11-15-2018
    Location
    Trinidad, West Indies
    MS-Off Ver
    Office 2007
    Posts
    7

    Need help creating a macro that prints one or all employee payslips from payroll database

    Pleasant evening, I need help in creating a macro that has the options through command buttons to print the current employee payslip or printing all employees payslips from the payroll database. I am new to VBA programming, any help will be greatly appreciated. Attached is a copy of the excel spreadsheet. Thank you in advance for any assistance.
    Attached Files Attached Files
    Last edited by Keith Rauseo; 11-17-2018 at 05:45 AM.

  2. #2
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,538

    Re: Need help creating a macro that prints one or all employee payslips from payroll datab

    It's of no help if you have to log in and don't have the particulars.

  3. #3
    Registered User
    Join Date
    11-15-2018
    Location
    Trinidad, West Indies
    MS-Off Ver
    Office 2007
    Posts
    7

    Re: Need help creating a macro that prints one or all employee payslips from payroll datab

    Sorry about that, all login particulars removed. Again thanks for any assistance.

  4. #4
    Registered User
    Join Date
    11-15-2018
    Location
    Trinidad, West Indies
    MS-Off Ver
    Office 2007
    Posts
    7

    Re: Need help creating a macro that prints one or all employee payslips from payroll datab

    Sorry about that, all login particulars removed. Again thanks for any assistance.

  5. #5
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,538

    Re: Need help creating a macro that prints one or all employee payslips from payroll datab

    How is the "current employee" determined?
    This should save all Payslips to .PDF files in the same Folder that houses your excel workbook.
    Please Login or Register  to view this content.
    Change the pdf routine to printing to your printer if you want that.

  6. #6
    Registered User
    Join Date
    11-15-2018
    Location
    Trinidad, West Indies
    MS-Off Ver
    Office 2007
    Posts
    7

    Re: Need help creating a macro that prints one or all employee payslips from payroll datab

    The current employee is determined by entering the Employee number. Thank you very much for your quick response. I got the following error message when running the macro.
    Attached Images Attached Images

  7. #7
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,538

    Re: Need help creating a macro that prints one or all employee payslips from payroll datab

    When you get the error, which line is highlighted?
    I have not tried it on your attachment yet.

    One thing you have to do is change the sheet called "PaySlip" (Capital S) to "Payslip" and don't change anything in the code or in the code change "Payslip" to "PaySlip" and don't change the sheet name.
    Last edited by jolivanes; 11-17-2018 at 08:02 PM. Reason: PaySlip problem

  8. #8
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,538

    Re: Need help creating a macro that prints one or all employee payslips from payroll datab

    Staying with the same type of code, this should work for a single employee.
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    11-15-2018
    Location
    Trinidad, West Indies
    MS-Off Ver
    Office 2007
    Posts
    7

    Re: Need help creating a macro that prints one or all employee payslips from payroll datab

    Thanks again jolivanes, I made the change to the PaySlip sheet name as indicated, the attached photo shows the highlighted area where the error message occurs.
    Attached Images Attached Images

  10. #10
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,538

    Re: Need help creating a macro that prints one or all employee payslips from payroll datab

    Do you have the "Create PDF Document" capability on your Excel?
    https://www.microsoft.com/en-us/down...ails.aspx?id=7
    If not, download/install it if you want it otherwise delete all of it and print to your local printer.

  11. #11
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,909

    Re: Need help creating a macro that prints one or all employee payslips from payroll datab

    @ jolivanes

    OP Office version says 2007 so exporting shouldn't be a problem.

    I suspect it's rather a name issue.

    PS
    On my system it works flawlessly.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  12. #12
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,538

    Re: Need help creating a macro that prints one or all employee payslips from payroll datab

    Hi Rudi (that's what it is, isn't it?)
    I do not remember if it is automatically part of 2007 or not. That's why I mentioned it.
    I also have not mentioned yet what I think of pictures! After all, Keith is pretty new (5 posts) to all of this.
    I do not know if his file is on an external system and if it is if that could create the problem.
    I guess these are questions that Keith has to answer for us. Maybe I never should have suggested to print to PDF but I prefer it myself.
    He can, as suggested, delete all of that and print whatever names are on the sheet. I would suggest to copy a bunch away from Column A so you don't print 100 pages just to try code.

  13. #13
    Registered User
    Join Date
    11-15-2018
    Location
    Trinidad, West Indies
    MS-Off Ver
    Office 2007
    Posts
    7

    Re: Need help creating a macro that prints one or all employee payslips from payroll datab

    Thanks Jolivanes, I downloaded the SaveAsPDF.exe, which resolved the error message. Both sub routines worked and payslips generated. All formulas from the payslip sheet are overwritten when the macro is run as the only issue. Is there a way of preventing that from happening?

  14. #14
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,538

    Re: Need help creating a macro that prints one or all employee payslips from payroll datab

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Both of course save as PDF files. I assume you know what to do if you want it printed directly to your printer.

  15. #15
    Registered User
    Join Date
    11-15-2018
    Location
    Trinidad, West Indies
    MS-Off Ver
    Office 2007
    Posts
    7

    Re: Need help creating a macro that prints one or all employee payslips from payroll datab

    Jolivanes, macro works perfect. Project solved. Thank you, Thank you very much. Hopefully I will be able to contribute in the near future.

  16. #16
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,538

    Re: Need help creating a macro that prints one or all employee payslips from payroll datab

    Thank you for letting us know.
    Good luck

+ 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. [SOLVED] Generating PDF Payslips form Payroll in Excel and sending to Individual e-mails in Outlook
    By Akintomiwa in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 08-27-2021, 08:47 PM
  2. Macro To save as PDF of employee payslips
    By yemnirmal in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 08-31-2015, 07:59 PM
  3. How to automate payslips from excel based payroll
    By Ibrahim Jinadu in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-19-2015, 04:25 PM
  4. [SOLVED] Macro To save as PDF of employee payslips
    By svippala in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 08-07-2014, 12:31 AM
  5. Need help in creating payslips for 25 employees.
    By hraditi in forum Excel Formulas & Functions
    Replies: 15
    Last Post: 07-26-2014, 11:08 AM
  6. [SOLVED] Generate payslips of employee on a list
    By oluwafog in forum Excel Programming / VBA / Macros
    Replies: 32
    Last Post: 04-17-2012, 11:16 PM
  7. Creating payslips
    By si_ako in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-01-2007, 01:32 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