+ Reply to Thread
Results 1 to 3 of 3

VBA Print / Save / Close

  1. #1
    Registered User
    Join Date
    12-28-2020
    Location
    Cabo Verde
    MS-Off Ver
    MS Office Professional Plus 2016 (64 bits)
    Posts
    2

    VBA Print / Save / Close

    Hello everyone.

    VBA is not my strongest point, so I'm asking if anyone can help me with this problem.

    I have an Excel Workbook with 9 sheets.
    In some of them, I want to have a button that, when clicked, prints the print area of that sheet, saves the whole workbook as the value of a cell (path is stored in another cell), and then closes the file.

    I would also like to disable save and save as from the menu, and force the user to use the button to save the workbook.

    Thank you in advance!

  2. #2
    Valued Forum Contributor ranman256's Avatar
    Join Date
    07-29-2012
    Location
    Kentucky
    MS-Off Ver
    Excel 2003
    Posts
    1,177

    Re: VBA Print / Save / Close

    in the workbook, enter VBE (alt-F11)
    in the project window (ctrl-R, left pane) ,in your project book, Dbl-click ThisWorkBook
    in the code area (right pane), at the top , the LEFT drop box ,click WORKBOOK
    paste the code below into the code area.

    Please Login or Register  to view this content.
    this will prevent user from save/save as
    BUT, your button must turn on the global variable gbSaveWB to bypass the save cancellation:

    Please Login or Register  to view this content.
    Last edited by ranman256; 12-29-2020 at 12:59 PM.

  3. #3
    Registered User
    Join Date
    12-28-2020
    Location
    Cabo Verde
    MS-Off Ver
    MS Office Professional Plus 2016 (64 bits)
    Posts
    2

    Re: VBA Print / Save / Close

    Thank you very much, ranman256!

    Should I then create one module with the second code (and the print/save/close code) which can be applied to all buttons/sheets, or should I create one module per button/sheet?

+ 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] Close and Save after inactivity, workbook keep re-opening, save and close, re-open... etc
    By QcHuldar in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-23-2020, 02:51 PM
  2. [SOLVED] Need help with making fields required before save/print/close
    By tnsvolley in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-07-2016, 07:01 PM
  3. Replies: 1
    Last Post: 10-25-2013, 06:10 PM
  4. Create watermark, save as pdf, print pdf, close file**
    By noobtron in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-18-2012, 06:26 PM
  5. Copy,Save,Print then Close
    By Geordie in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-11-2010, 01:48 AM
  6. want to save, print and close wb
    By sakung in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-11-2006, 06:26 AM
  7. I like to open a folder,auto print,save then close
    By tied of opening files in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-22-2005, 06:06 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