+ Reply to Thread
Results 1 to 17 of 17

Macro to Export from Excel to .pdf

  1. #1
    Forum Contributor
    Join Date
    06-07-2018
    Location
    Newcastle Upon Tyne, England
    MS-Off Ver
    365
    Posts
    143

    Macro to Export from Excel to .pdf

    Can anyone recommend a better Macro to be able to do the following:

    1. Choose where you can save the exported file

    2. MAXIMUM quality of export

    Here is what I'm currently using:

    Please Login or Register  to view this content.
    Thanks as always!

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

    Re: Macro to Export from Excel to .pdf

    Let's start with this.
    Please Login or Register  to view this content.
    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.

  3. #3
    Forum Contributor
    Join Date
    06-07-2018
    Location
    Newcastle Upon Tyne, England
    MS-Off Ver
    365
    Posts
    143

    Re: Macro to Export from Excel to .pdf

    The codes not working unfortunately, I do appreciate your time though!

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

    Re: Macro to Export from Excel to .pdf

    And what exactly doesn't work ?

    You asked for a Folderpicker and that's what you got.

  5. #5
    Forum Contributor
    Join Date
    06-07-2018
    Location
    Newcastle Upon Tyne, England
    MS-Off Ver
    365
    Posts
    143

    Re: Macro to Export from Excel to .pdf

    Apologies if I'm being a fool here, just my .jpg export code automatically pops up with a folder picker without me typing it into the code:
    Attached Images Attached Images

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

    Re: Macro to Export from Excel to .pdf

    Do you have any other code still running while trying to execute ExportPDF ?

  7. #7
    Forum Contributor
    Join Date
    06-07-2018
    Location
    Newcastle Upon Tyne, England
    MS-Off Ver
    365
    Posts
    143

    Re: Macro to Export from Excel to .pdf

    No I closed the document and re-opened it to be sure.

    Here is the code I use for .jp with folder picker:

    Please Login or Register  to view this content.
    I can't write code I can just take bits and pieces from people and sometimes get things working but then other times like now I get a bit stuck.

    Thanks

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

    Re: Macro to Export from Excel to .pdf

    I'm sorry but I don't see the connection between this code and the code I posted you.

    These are completely seperate things.

  9. #9
    Forum Contributor
    Join Date
    06-07-2018
    Location
    Newcastle Upon Tyne, England
    MS-Off Ver
    365
    Posts
    143

    Re: Macro to Export from Excel to .pdf

    I'm just giving you an example of something I have that works for .jpg and tried to then get the same outcome with .pdf

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

    Re: Macro to Export from Excel to .pdf

    Something like this then ?
    Please Login or Register  to view this content.
    Last edited by bakerman2; 06-16-2018 at 06:33 PM.

  11. #11
    Forum Contributor
    Join Date
    06-07-2018
    Location
    Newcastle Upon Tyne, England
    MS-Off Ver
    365
    Posts
    143

    Re: Macro to Export from Excel to .pdf

    Unfortunately another error message, apologies.

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

    Re: Macro to Export from Excel to .pdf

    There's a b too much in End Sub. My bad.

  13. #13
    Forum Contributor
    Join Date
    06-07-2018
    Location
    Newcastle Upon Tyne, England
    MS-Off Ver
    365
    Posts
    143

    Re: Macro to Export from Excel to .pdf

    Attached Images Attached Images

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

    Re: Macro to Export from Excel to .pdf

    You are probably using Option Explicit so you have to put this
    Please Login or Register  to view this content.
    as first line of the code

  15. #15
    Forum Contributor
    Join Date
    06-07-2018
    Location
    Newcastle Upon Tyne, England
    MS-Off Ver
    365
    Posts
    143

    Re: Macro to Export from Excel to .pdf

    That has now stopped me from having to add a file location into the code however, it automatically saves to my desktop and then opens the 'SaveAs' option but there is no PDF option and it only lets me select 'All Files (*.*)'

    My problem is that this document is for multiple people to use so they need to get the option of where to save the PDF file once they click the macro button.

    Any further suggestions welcome and appreciated

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

    Re: Macro to Export from Excel to .pdf

    Please Login or Register  to view this content.
    This code let's you select a folder and the oppertunity to fill in a filename. you don't need to add or select an extension because it will be added automatically upon saving.
    You can even refer to a certain cell to fill in a standard filename.
    After clicking OK the file will be saved in the location with the filename which you have filled in.
    How much easier can it get.

  17. #17
    Forum Contributor
    Join Date
    06-07-2018
    Location
    Newcastle Upon Tyne, England
    MS-Off Ver
    365
    Posts
    143

    Re: Macro to Export from Excel to .pdf

    That's working perfectly... much appreciated Bakerman2, top work!
    Last edited by davo3286; 06-17-2018 at 06:50 AM.

+ 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] Macro to Export from Excel to .jpg
    By davo3286 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-14-2018, 06:43 AM
  2. [SOLVED] Data Export Macro works in Excel 2013 but not Excel 2007
    By margentieri in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-27-2016, 10:49 AM
  3. Macro export from excel
    By Human2014 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 09-18-2015, 01:58 PM
  4. Macro to export from SAP to Excel
    By LeanAccountant in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-12-2015, 05:58 AM
  5. Replies: 0
    Last Post: 02-20-2013, 09:57 AM
  6. 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
  7. Replies: 2
    Last Post: 07-18-2012, 11:17 PM

Tags for this Thread

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