+ Reply to Thread
Results 1 to 4 of 4

Save PDF to users desktop and use value of specific cell in part of the name

  1. #1
    Registered User
    Join Date
    01-26-2011
    Location
    Canada
    MS-Off Ver
    Office 365
    Posts
    49

    Question Save PDF to users desktop and use value of specific cell in part of the name

    Good Day!

    In advance my apologies, I'm sure this is a very simple question. Unfortunately I don't understand much of VBA and usually manage to piece the macros that I need together with the power of google or recording a macro. In this particular case I am stuck and I'm hoping somebody can help me.

    So I have an excel file with several tabs, which I want to save as a PDF on the users desktop. This macro works like a charm :

    Please Login or Register  to view this content.
    It saves all the sheets that I want onto my desktop as "myfilename.pdf".

    What i would like it to do is replace "myfilename" with the value of Title!C13 instead. I believe the correct reference looks like this
    Please Login or Register  to view this content.
    But I can't figure out how to tie it into this line

    Please Login or Register  to view this content.
    I would much appreciate help with this!

    Thanks

    Maike

  2. #2
    Forum Expert
    Join Date
    10-02-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    1,222

    Re: Save PDF to users desktop and use value of specific cell in part of the name

    Likely something like:

    Please Login or Register  to view this content.
    You could also save the value of the cell into a variable and use the variable in place of the "Worksheets("Title").Range("C13").Value" above.

  3. #3
    Forum Expert
    Join Date
    10-02-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    1,222

    Re: Save PDF to users desktop and use value of specific cell in part of the name

    Its also worth mention that you likely want to check that the cell doesnt contain characters invalid for use in a file name.

    I usually use a function to check the string for the filename and replace any invalid characters with a valid symbol like underscore.

    Here is my snippet for this, you can adjust as needed:

    Please Login or Register  to view this content.
    So essentially you adjust your code and mine so that your gets the string from the cell, splits it into an array and then calls the function to clean it up if needed and then use the result of the function (either direct or saved back to a variable as part of your saveas instead of the cell contents direct
    Last edited by Zer0Cool; 10-20-2017 at 01:50 PM.

  4. #4
    Registered User
    Join Date
    01-26-2011
    Location
    Canada
    MS-Off Ver
    Office 365
    Posts
    49

    Re: Save PDF to users desktop and use value of specific cell in part of the name

    Quote Originally Posted by Zer0Cool View Post
    Likely something like:

    Please Login or Register  to view this content.
    You could also save the value of the cell into a variable and use the variable in place of the "Worksheets("Title").Range("C13").Value" above.
    I tried that and it errored out. Must've missed a quote or space or something somewhere.. Thank you Zer0

+ 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. Change my vba code to save excel file directly to any users desktop not via c drive
    By galbatrox9 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-22-2016, 01:22 AM
  2. Save as button to desktop working for all users
    By Niels57440 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-30-2016, 07:52 AM
  3. VBA to Save the Selected Area as a PDF to the Users DeskTop
    By Sean Gillan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-15-2015, 05:10 PM
  4. [SOLVED] VBA: Create a new folder on any users desktop and save the file as value in cell (A51)
    By nwb in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-24-2014, 11:02 PM
  5. Save as CSV to specific folder on desktop and current date as filename
    By stokiejames09 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-28-2013, 05:52 PM
  6. [SOLVED] Macro to save mail merged word docs to users desktop and with a desired file name
    By bonny24tycoon in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-22-2012, 12:27 PM
  7. [SOLVED] How would I save a text file to a folder on the users desktop without knowing the path?
    By 111StepsAhead in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-21-2012, 01:36 PM

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