+ Reply to Thread
Results 1 to 5 of 5

VBA that saves file as PDF, browses for location, names PDF

  1. #1
    Registered User
    Join Date
    07-17-2020
    Location
    New York
    MS-Off Ver
    2020
    Posts
    24

    VBA that saves file as PDF, browses for location, names PDF

    Hello, I need to learn VBA code to do the following when a button (or multiple buttons) are clicked:

    1) Save the excel file as a PDF
    2) Allow user to browse for save location
    3) Name that PDF from a different sheet using multiple cells


    I have attached a sample file that a user will input data for multiple categories. For each category there is a corresponding code name that has to be included in the file name. The file name will not be the name of the data sheet, it will be the name of either Template A's saved file or Template B's saved file. There are only 2 options for "Type", Type A and Type B and that is what determines which template gets named.

    This will help me SO MUCH I hope someone can help me please. Thanks!
    Attached Files Attached Files

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,474

    Re: VBA that saves file as PDF, browses for location, names PDF

    There are tons of threads on this in the forum and on the www, what in particular did you need help with?

  3. #3
    Registered User
    Join Date
    07-17-2020
    Location
    New York
    MS-Off Ver
    2020
    Posts
    24

    Re: VBA that saves file as PDF, browses for location, names PDF

    Hi, thanks for your reply.
    I cannot find a thread that talks about using multiple cells and combines them for 1 name to save as. I am new to this and am getting errors when I take codes from other threads so I was hoping someone could help me with a personalized one because I never know what goes wrong in the code. If you could look at this file that I attached, when I try to click "Select Folder..." I get an error, "Run-time error '91': Object variable or With block variable not set". Also if I try to click on "Show Form..." it gives me the error, "Run-time error '1004': Application-defined or object-defined error". Do you know what I am doing wrong?
    Attached Files Attached Files

  4. #4
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,474

    Re: VBA that saves file as PDF, browses for location, names PDF

    Oh, i clicked the button, selected the folder opened the UserForm and saved as PDF with no issues at all.

    Obviously, this does not help with your situation. What line gets highlighted when the code errors?

  5. #5
    Registered User
    Join Date
    07-17-2020
    Location
    New York
    MS-Off Ver
    2020
    Posts
    24

    Re: VBA that saves file as PDF, browses for location, names PDF

    It highlights, ".Title = saywhat" I probably should mention that I have a Mac Version 10.15.5... this is probably complicating things but the mac is all I have
    Do you know why this line is highlighted?

+ 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. Add to ActiveSheet.PrintOut so that it names the sheet and saves it automatically?
    By kewellh in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-14-2019, 07:41 PM
  2. macro that browses external file and copy its name to a certain cell of a worksheet
    By mlcfexcel in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-15-2015, 08:04 AM
  3. [SOLVED] Macro that saves a copy of document in a different folder location
    By glide2131 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-28-2014, 10:41 AM
  4. Replies: 1
    Last Post: 10-31-2012, 11:19 AM
  5. Macro Saves & Names File with Current Date & Range
    By BluTalon in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-30-2008, 03:51 PM
  6. build a macro that saves & names a file with the current day's date
    By mariusescu in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-09-2008, 10:22 AM
  7. Replies: 0
    Last Post: 04-13-2005, 03:06 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