How to force user to enable macros easily in Excel (example)

Who I am
Philippe Gloaguen
@philippegloaguen
EXTERNAL REFERENCES:

vgr.com gamedesigning.org Reddit.com

Author and references

Sometimes users wonder if they can record a macro in an Excel sheet or What is a macro and its usefulness? However, if you are an advanced user and have already created macros in Excel, we recommend that you read this article with which you will learn how to force user to enable macros easily in excel

    What are macros in Excel?

    Le macro in Excel they are actions that allow you to perform repetitive tasks. This way, Microsoft Excel can perform a series of actions as often as needed. Macros are part of the Excel options and are activated via the "Developer" tab.



    How do macros work in Excel?

    Macros in Excel work through a series of code instructions organized in modules . The syntax for each function is based on the Visual Basic application. Therefore, you need to know this application to be able to edit and edit a macro in Excel.

    How to force user to enable macros in Excel easily

    If you want to force the user to easily enable macros in Excel, it is necessary hide all the sheets that make up the workbook and leave only one visible where the user will be asked to enable macros. To achieve this, follow the steps we explain below.

    Create a macro to open the Excel file

    First of all, you need to learn how to make a macro with VBA in Excel. With the new macro you will make all sheets in the Excel workbook visible and make the initial sheet invisible. To do this, press the "Alt + F11" keys and select "ThisWorkbook" on the left of the panel that is part of the Visual Basic editor.



    Read How to change QWERTY keyboard in AZERTY in simple steps

    The macro must be addressed to the Open event. Therefore, select "Work Folder" and "Open". Then, enter the following syntax for the event (Each period includes a new line, they are not included in the final code):

    • Private Secondary Workbook_Open ()
    • Per ogni ws In ThisWorkbook.Worksheets
    • ws.Visible = xlSheetVisible
    • Avanti in
    • Sheets ("Inicio"). Visible = xlVeryHidden
    • End below

    Create another macro to hide sheets when Excel closes

    You need to create another macro to make sheets invisible or hide when Microsoft Excel is closed. To do this, go back to the Visual Basic editor and click on "WorkBook", then select the "BeforeClose" event.

    Then a add a code to make the "Home" sheet visible and hide the other sheets one by one, as follows (Each bullet includes a new line, they are not included in the final code):

    • Private Secondary Workbook_BeforeClose (Cancel as Boolean)
    • Sheets ("Inicio"). Visible = xlSheetVisible
    • Per ogni ws In ThisWorkbook.Worksheets
    • If ws.Name & lt; & gt; "Inicio" Then
    • ws.Visible = xlVeryHidden
    • End if
    • Avanti in
    • ActiveWorkbook.Save
    • End subtitle

    Is it possible to force the user to enable macros in Excel easily via this procedure?

    It is in fact possible to force the user to enable macros in Excel using the procedure applied. It will work as follows: when you try to open the workbook in Microsoft Excel, all the sheets in it will be hidden and only one will be visible.


    This "Home" sheet will be used for indicate that macros must be enabled . When you perform this task, the "Open" event code will run, which will show the sheets that were hidden.



    Therefore, the user is forced to enable macros to view the entire workbook in Excel . The macro, which is executed before closing the file, allows you to hide the sheets that were activated again and to make the "Start" sheet visible again to the user.

    Read How to change or modify my mobile email or email account

    Why should I force the user to enable macros?

    Both the online versions of Excel and the desktop applications have a set of user-manageable functions. This is the case with the function "enable macro" which you should consider if you have any macros encoded in your Excel file.


    If a user does not enable macros , it will not be able to perform any encrypted actions . For this reason, if macros are essential in an Excel file, be sure to force the user to enable them via the security warning presented by the application Security warning presented by the application.

    add a comment of How to force user to enable macros easily in Excel (example)
    Comment sent successfully! We will review it in the next few hours.