+ Reply to Thread
Results 1 to 14 of 14

Save, Print, and Delete on Command

  1. #1
    Registered User
    Join Date
    07-30-2020
    Location
    Charleston, SC
    MS-Off Ver
    Office 365
    Posts
    30

    Question Save, Print, and Delete on Command

    I need to work out a script that responds to a specific entry in column 1 on Sheet2, such as "Print"
    Once the command is entered, I need it to save the Print_Area as a PDF titled by Sheet2!R1C2 and print it to a certain network printer (Set as PC default), then delete the named cell range, "Worksheet"
    I have found bits and pieces of code that can accomplish this, but haven't been able to successfully piece them together. I am attaching a sample workbook for clarity. I'm fairly new to VBA, so I thoroughly appreciate any help you can provide on this!
    Attached Files Attached Files
    Last edited by singinwes; 08-18-2020 at 03:21 PM.

  2. #2
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,387

    Re: Save, Print, and Delete on Command

    .
    Take note that nothing in your written description above matches the attached workbook (rows, columns, named cell range).
    You'll need to correct before a reasonable answer can be given.

  3. #3
    Registered User
    Join Date
    07-30-2020
    Location
    Charleston, SC
    MS-Off Ver
    Office 365
    Posts
    30

    Re: Save, Print, and Delete on Command

    I switched the word row for column in the first line, everything else matches. Fixed my mistake, thank you.

  4. #4
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,387

    Re: Save, Print, and Delete on Command

    .
    PRINT AREA is considered everything above the work PRINT but not the Column Header ?

  5. #5
    Registered User
    Join Date
    07-30-2020
    Location
    Charleston, SC
    MS-Off Ver
    Office 365
    Posts
    30

    Re: Save, Print, and Delete on Command

    Oh weird, my Print_Area didn't stick. Print_Area would just be Sheet1!R1C1:R11C2

  6. #6
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,387

    Re: Save, Print, and Delete on Command

    .
    Ok .. and hopefully lastly ... what is "delete the named cell range, "Worksheet" ?

  7. #7
    Registered User
    Join Date
    07-30-2020
    Location
    Charleston, SC
    MS-Off Ver
    Office 365
    Posts
    30

    Re: Save, Print, and Delete on Command

    Check the name manager, that cell range is in there. It's basically everything except the headers.

  8. #8
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,387

    Re: Save, Print, and Delete on Command

    .
    Sorry. Your downloaded example does not show "Worksheet".

    In any case, paste this macro in the Sheet2 module :


    Please Login or Register  to view this content.

    Paste the following in a Regular Module :

    Please Login or Register  to view this content.
    In the regular module, change "gagli" (located in the path), to the name of your computer.

    The macros save the range to the Desktop as a PDF. You can print it from there.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    07-30-2020
    Location
    Charleston, SC
    MS-Off Ver
    Office 365
    Posts
    30

    Re: Save, Print, and Delete on Command

    I can work with this, thank you! As it stands, it names the pdf with just the date. How can I add to that title?

  10. #10
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,387

    Re: Save, Print, and Delete on Command

    .
    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    07-30-2020
    Location
    Charleston, SC
    MS-Off Ver
    Office 365
    Posts
    30

    Re: Save, Print, and Delete on Command

    Hmm, I entered that in and updated the filepath and it gives me a runtime error and "Document not saved." Debugger then highlights the whole thing.

  12. #12
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,387

    Re: Save, Print, and Delete on Command

    .
    Post your code.

  13. #13
    Registered User
    Join Date
    07-30-2020
    Location
    Charleston, SC
    MS-Off Ver
    Office 365
    Posts
    30

    Re: Save, Print, and Delete on Command

    Please Login or Register  to view this content.

  14. #14
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,387

    Re: Save, Print, and Delete on Command

    .
    I changed your computer name GW23140 for mine and successfullly ran the macro here.

    The name of your computer that you are using must be the cause of the error.

+ 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. Print # command to print copies & serialize
    By Dean Zuki in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-01-2016, 12:26 AM
  2. VBA code to create command button. Print all sheets then delete command button.
    By Declamatory in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-15-2015, 05:18 PM
  3. Save multiple sheet/print sheet with one command button
    By GJR in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-23-2014, 03:06 PM
  4. Macro Command Button: Combine Save As CSV and Delete Unsed Rows Macros
    By mustng_sally in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-15-2013, 10:41 AM
  5. Print Macro errors on final print command. Run-time error '1004':
    By Steverizer in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-05-2013, 06:41 PM
  6. [SOLVED] Change Print Command or add a new print command
    By Daniel R. Young in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-11-2005, 01:20 AM

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