+ Reply to Thread
Results 1 to 10 of 10

Help improving a macro to create pdf

  1. #1
    Registered User
    Join Date
    03-29-2014
    Location
    Portugal
    MS-Off Ver
    Excel 2013
    Posts
    73

    Help improving a macro to create pdf

    Hi all,

    Need some assistance on how to improve the code bellow to save a pdf with a filename equal to the value of "E16"

    Thanks in advance....!

    Please Login or Register  to view this content.
    Last edited by tfilipe; 06-23-2018 at 06:09 PM.

  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: Help improving a macro to create pdf

    Since you didn't really specify the problem I guess it was the opendialog part.
    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
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,532

    Re: Help improving a macro to create pdf

    E16 on what sheet?

    If the file name is in E16 then get rid of this

    Please Login or Register  to view this content.
    and modify this

    Please Login or Register  to view this content.
    Qualify Range("16") with the sheet name if it is not the active sheet.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  4. #4
    Registered User
    Join Date
    03-29-2014
    Location
    Portugal
    MS-Off Ver
    Excel 2013
    Posts
    73

    Re: Help improving a macro to create pdf

    Thanks bakerman2 and 6String..!

    @6StringJazzer Yes Range E16 is on the active sheet, And I would like the file name to be [Booking Confirmation_(Range("E16")] how to write that?

    Booking Confirmation is fixed
    Range E16 is a Variable

  5. #5
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,532

    Re: Help improving a macro to create pdf

    Please Login or Register  to view this content.
    I suggested you remove GetSaveAsFilename. I may not have understood your requirements. GetSaveAsFilename will allow the user to save the file using any name he wants, in any folder he wants. The default will be the argument you provided but the user can change it. In the version I proposed the user gets no choice of file name or folder.

    Can you clarify what you want to happen?

  6. #6
    Registered User
    Join Date
    03-29-2014
    Location
    Portugal
    MS-Off Ver
    Excel 2013
    Posts
    73

    Re: Help improving a macro to create pdf

    Hi String,

    Sorry maybe I wasn't very clear...!

    The code as I had it, would open a dialog box to finish the filename and choose a folder where to save it to.

    What I am after is to automate the filename procedure since we were entering the value of E16 as part of the file name anyway, i.e. Booking Confirmation_"E16"

    As I understand, the code as you provided does just that, but where is it saving the PDF to? Desktop?

  7. #7
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,532

    Re: Help improving a macro to create pdf

    It is saving the file to "current folder" which could be your Documents folder, or where your Excel file is saved. If you want to make it explicitly the same folder then:

    Please Login or Register  to view this content.
    or specify whichever other folder you would like to use instead.

  8. #8
    Registered User
    Join Date
    03-29-2014
    Location
    Portugal
    MS-Off Ver
    Excel 2013
    Posts
    73

    Re: Help improving a macro to create pdf

    How would I change this code to save the pdf to the desktop please?

    Newby question I know

    Please Login or Register  to view this content.

  9. #9
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,532

    Re: Help improving a macro to create pdf

    Replace tfilipe with whatever your Windows user name is:

    Please Login or Register  to view this content.

  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: Help improving a macro to create pdf

    To be on the safe side you have two possibilities.
    Please Login or Register  to view this content.
    or
    Please Login or Register  to view this content.
    So your code would look like
    Please Login or Register  to view this content.
    or
    Please Login or Register  to view this content.

+ 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. Improving this macro?
    By terrypin in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-23-2018, 08:28 AM
  2. [SOLVED] Improving existing macro to flip data
    By axtryo in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-20-2017, 03:05 AM
  3. Urgent Help with Improving a Balancing Macro
    By Simon Gleeb in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-22-2017, 11:11 PM
  4. [SOLVED] Improving a macro, so that it either hides, or unhides all the columns
    By davidx in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 11-11-2015, 05:00 AM
  5. [SOLVED] Inefficient 'select sheets' macro - needs improving pls!
    By TheRobsterUK in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-13-2013, 06:46 AM
  6. [SOLVED] improving functionality of lengthy macro
    By Zealotwraith in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-26-2013, 11:43 AM
  7. Improving my format-macro
    By Jaymond Flurrie in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 11-02-2006, 08:40 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