+ Reply to Thread
Results 1 to 14 of 14

Macro to export to pdf

  1. #1
    Registered User
    Join Date
    08-04-2012
    Location
    cardiff
    MS-Off Ver
    Excel 2007
    Posts
    49

    Macro to export to pdf

    I have a workbook that calculates times based on certain start time, schedules etc and then using a macro designed sometime ago by a colleague prints all the selected sheets to the default printer - say from rider 1 (lowest number) to rider 10 (highest number) but could be up to 500 sheets, however I would like to amend the macro so it exports the data in one file in a pdf, I've tried just changing the default printer to the microsoft pdf option but that then requires me to name each rider page separately and I'd like them all in one folder to be able to email over - any help would be appreciated I've pasted the code I have below

    Thanks



    Please Login or Register  to view this content.
    Last edited by suedavies; 05-16-2016 at 11:31 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    01-08-2011
    Location
    Portsmouth, England
    MS-Off Ver
    Excel 2007 to 2016
    Posts
    456

    Re: Macro to export to pdf

    You could try to save as pdf instead of printing:

    Please Login or Register  to view this content.
    This creates a single pdf of all sheets in the workbook. Is that what you needed?

    If not, could you attach a small sample workbook for us to review.

  3. #3
    Registered User
    Join Date
    08-04-2012
    Location
    cardiff
    MS-Off Ver
    Excel 2007
    Posts
    49

    Re: Macro to export to pdf

    Hi Shirley

    Yes I want to save as all of the output to one pdf, I managed to change the code to do this but it was asking me to save each rider timesheet as separate pdf's and I have up to 500, where would I put the code you have quoted above and what do I need to delete from the existing code to get it to work?

    Thanks for your time

  4. #4
    Registered User
    Join Date
    08-04-2012
    Location
    cardiff
    MS-Off Ver
    Excel 2007
    Posts
    49

    Re: Macro to export to pdf

    attached zip file of workbook

    thanks

  5. #5
    Valued Forum Contributor
    Join Date
    01-08-2011
    Location
    Portsmouth, England
    MS-Off Ver
    Excel 2007 to 2016
    Posts
    456

    Re: Macro to export to pdf

    Hi Sue,

    Try taking out the line below your send timecards to printer (I'd just put a single quote mark in front of the instruction while you test it in case you want to put it back!)

    I think you will need to put the new "save" code after the Loop ends (just before you save your workbook). From what I can see in the code, the print instruction happens for each separate rider number because it's inside the loop, so if you put the save in there it would create a pdf of the whole workbook every time the rider number changes which is probably not what you want

    Give it a try and see how you get on.

    Shirley

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

    Re: Macro to export to pdf

    You can keep code until Print-part (can do with a bit of tweaking but is ok for now).
    Instead of printing you need to add a new worksheet and copy the PrintArea to it. Repeat this for every rider until finished. Then group all newly created sheets and send to Pdf.
    Delete all sheets you just created to have a blank template again.
    I'll see if I find the time to put the code together for this later today.

  7. #7
    Registered User
    Join Date
    08-04-2012
    Location
    cardiff
    MS-Off Ver
    Excel 2007
    Posts
    49

    Re: Macro to export to pdf

    thanks bakerman2 that would be helpful if you could look a the code, I realise that the coding is probably a bit outdated as it was done in 2002 but didn't want to mess with what has been working for me, I just need to be able to put all the results of the macro into one pdf to send to be printed

    Shirleyxls will try yours as well later today

  8. #8
    Registered User
    Join Date
    08-04-2012
    Location
    cardiff
    MS-Off Ver
    Excel 2007
    Posts
    49

    Re: Macro to export to pdf

    I have just realised the first code I posted was some that I had altered from the original and had added the following : PrintTofile:=True,

    Please Login or Register  to view this content.

  9. #9
    Valued Forum Contributor
    Join Date
    01-08-2011
    Location
    Portsmouth, England
    MS-Off Ver
    Excel 2007 to 2016
    Posts
    456

    Re: Macro to export to pdf

    Hi Sue,
    This wouldn't matter for my suggestion as you can take out the line where you send the file to print; the solution I suggest just saves the workbook in pdf format.

    You could give it a try maybe although bakerman2 is doing some code for you anyway.

  10. #10
    Registered User
    Join Date
    08-04-2012
    Location
    cardiff
    MS-Off Ver
    Excel 2007
    Posts
    49

    Re: Macro to export to pdf

    Hi Bakerman2, sorry I'm very much a newbie at macros & code can you explain in idiots language what I need to do, when the macro runs I want it to calculate the timecard for all riders and then save the complete output to one pdf file, I fiddled with the code and managed to get it to export to pdf but it was asking for me to name and save each timecard individually, I could do this for a handful but I anticipate having a couple of hundred. Any further help would be most appreciated

    sue

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

    Re: Macro to export to pdf

    Sorry for the delay but been really busy at work last few days.
    Try example file.
    The only thing left to do before running code is adjusting path to save pdf-file to.
    Please Login or Register  to view this content.
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    08-04-2012
    Location
    cardiff
    MS-Off Ver
    Excel 2007
    Posts
    49

    Re: Macro to export to pdf

    thanks Bakerman 2 fantastic

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

    Re: Macro to export to pdf

    You're welcome and thanks for the rep.

  14. #14
    Registered User
    Join Date
    08-04-2012
    Location
    cardiff
    MS-Off Ver
    Excel 2007
    Posts
    49

    Re: Macro to export to pdf

    Hi Bakerman2

    Sorry to be bothering you again, you kindly helped with the macro code to export my results to a single pdf file which works fab but I have a quick question, on my original code if there was no check time shown it left the cells in the actual timecard as blanks, in the code you gave me it prints zero's, can you explain what I need to change to ensure that if there is nothing to display I get a blank cell rather than a "0"
    Kind regards
    Sue

+ 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. Macro to export and import a module and assigning different macro automatically
    By Libster78 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 11-14-2015, 06:31 PM
  2. Macro to Export a Sheet but also export a macro?
    By ChrisF79 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-20-2013, 12:26 PM
  3. I would need a macro to export data from base example workbook to export worbook
    By slato8 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-01-2012, 11:21 AM
  4. Help with an export macro
    By iisjman07 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-28-2011, 01:35 PM
  5. Export XML via a macro
    By DangerMouse in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-02-2006, 08:37 AM
  6. export to csv macro
    By PM4 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-01-2006, 04:30 PM
  7. Macro to Export XML
    By DangerMouse in forum Excel General
    Replies: 1
    Last Post: 04-10-2006, 09:49 AM
  8. Export CSV Macro
    By g.wattel in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-14-2005, 10:22 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