Posts by max_lux


    I have a workbook which I have been working on for 5 years. Up until now I have used print and preview buttons from specific informational gathering pages. Print pages are different than the pages where the information is gathered, and other than previewing or printing, I do not allow the user access to these sheets.

    I am about to add a custom toolbar to my workbook, and would like to know if it is possible to print a different sheet and then return to the sheet you were at, and if so, could you modify my example of some code so that that would be possible

    Thanks very much for your help.

    Re: MSGBOX called by if statement

    I have done this via roys suggestion. Without use of vb, it is impossible to have an actual msgbox used, however, with a few formulas (which I left easy to see, but can be formatted). I left the cells in yellow so you will know which ones i have put formulas in. With a true formula, a couple if formulas, and a cheat concectonate formula (which could also be nested in an if formula should it be required in that cell).

    To see it work:
    add any of product a
    add 2 or more of product d

    I hope this helps you.

    Re: Print Preview (Setup,Margins,*Page Break Preview*) Disable

    Thanks for the help, but I think you misunderstood what I am looking to do.

    I have a workbook which I am trying to make as foulup free as possible, because it must be distributed to over 50 people, and some of them are still learning Windows 95 (well not quite, but I hope you get my point; most of them are not advanced users). One guy still runs an old laptop with a 640 by 480 screen even!

    What I have done is:
    - disabled worksheet menu bar and close all other toolbars
    - disabled commandbar functions (min,restore,exit)
    - disabled toolbar customization (add,edit buttons)
    - disabled right click (context menus)
    - disabled toolbar list (access to running another toolbar which the user has edited and added buttons of their choosing)
    - all actions are performed by macros initiated by buttons, other than the default shortcut keys
    - I have one sheet very hidden but which becomes visible when either print previewing or printing only, initiated by a button as described above. Lets call this sheet Sheet1Report

    My problem:

    I have a report (Sheet1Report) which I need the user to be able to print preview prior to printing (error checking of visually contiguous information), however, I do not wish the user to be able to edit margins or print settings. I cannot successfully disable the functions which will stop the user from being able to do this. I can grey them out for initially, but they become functional upon a keypress, therefore the previously quoted lines of code do not fulfill the requirements, other than visually, and only until the user presses either "close" or "page break view" when in print preview.

    Re: Print Preview (Setup,Margins,*Page Break Preview*) Disable

    On a further note, the codes:

    ActiveSheet.PrintPreview False


    Application.Dialogs(xlDialogPrintPreview).Show False

    Both do the same thing, grey out the setup and margin buttons, but:

    1) if you press the print preview button, it enables the two buttons and keeps the print preview open. If you press normal view (second press of the same button) it will exit print preview.

    2) if you press the close button, it enables the two buttons and keeps the print preview open. If you press close (second press of the same button) it will exit print preview.

    Re: Closing workbook with dynamic name

    If you want to close the other workbook, which would be the inactive window(of any name, therefore dynamic), assuming you only have two workbooks open :

    Sub CloseOther()
    End Sub

    or (which is better, but must have a static name), no matter how many workbooks are open:

    Sub CloseOther()
    End Sub

    Let me know if this wasn't what you were trying to do. I may have misunderstood what you want to do.


    I know that the thread :

    was closed because everyone thought the problem was solved, but it was only partially solved. The question was "How to disable the setup and margin buttons when in print preview?".

    The answer came as to use the following code...

    ActiveSheet.PrintPreview False

    ...which does actually grey the two buttons, but then, if one selects page break preview, it ungreys them and access is given to those two buttons.

    Therefore, my question is, does anyone or can anyone perhaps think of a property/ method that might be used to remove the "page break preview button" as well?

    Thanks in advance,


    Oh, by the way, this is an awesome forum and website. Many thanks to whomever run(s) it.