Forcing Excel users to enable macros before code runs [duplicate]










0















This question already has an answer here:



  • Excel VBA: Enabling Macro Settings

    4 answers



I would like to know, whether it is possible to force the users of my sheet, to enable macros before using.



And having my macro put on hold, before they say "OK" to enabling macros.



Thank you in advance :)










share|improve this question













marked as duplicate by Darren Bartrup-Cook, cyboashu, Wizhi, Billal Begueradj, lagom Nov 13 at 5:28


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.










  • 2




    If there were an answer to this, the would be a hole in macro security big enough to drive a truck through.
    – Comintern
    Nov 12 at 15:15










  • Your macro doesn't need to be put on hold because it won't be running until the user clicks "OK" to enabling macros. There is no way with a macro to overwrite this though as that's the entire point of excel prompting the user to enable them for the workbook. If you need that level of control on the user's machine, then a Macro is not the way to go. You could use VSTO and/or Excel Interop in C#/Visual Studio though to write up a workbook that acts more like a traditional application on the users machine. Bit of a learning curve there though.
    – JNevill
    Nov 12 at 15:15











  • Well, my Macro from “Private sub Workbook Open()” doesn’t run upon opening, and not after allowing macros.
    – Patrick S
    Nov 12 at 15:19






  • 1




    Is the question whether it's possible to force users to enable macros or why your Workbook_Open event isn't firing?
    – Darren Bartrup-Cook
    Nov 12 at 15:23






  • 1




    Well, would prefer to force them to accept first, but seemed as if that wasn’t possivble. So if I can get a solution for Workbook_Open, it’ll do the trick :)
    – Patrick S
    Nov 12 at 15:28















0















This question already has an answer here:



  • Excel VBA: Enabling Macro Settings

    4 answers



I would like to know, whether it is possible to force the users of my sheet, to enable macros before using.



And having my macro put on hold, before they say "OK" to enabling macros.



Thank you in advance :)










share|improve this question













marked as duplicate by Darren Bartrup-Cook, cyboashu, Wizhi, Billal Begueradj, lagom Nov 13 at 5:28


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.










  • 2




    If there were an answer to this, the would be a hole in macro security big enough to drive a truck through.
    – Comintern
    Nov 12 at 15:15










  • Your macro doesn't need to be put on hold because it won't be running until the user clicks "OK" to enabling macros. There is no way with a macro to overwrite this though as that's the entire point of excel prompting the user to enable them for the workbook. If you need that level of control on the user's machine, then a Macro is not the way to go. You could use VSTO and/or Excel Interop in C#/Visual Studio though to write up a workbook that acts more like a traditional application on the users machine. Bit of a learning curve there though.
    – JNevill
    Nov 12 at 15:15











  • Well, my Macro from “Private sub Workbook Open()” doesn’t run upon opening, and not after allowing macros.
    – Patrick S
    Nov 12 at 15:19






  • 1




    Is the question whether it's possible to force users to enable macros or why your Workbook_Open event isn't firing?
    – Darren Bartrup-Cook
    Nov 12 at 15:23






  • 1




    Well, would prefer to force them to accept first, but seemed as if that wasn’t possivble. So if I can get a solution for Workbook_Open, it’ll do the trick :)
    – Patrick S
    Nov 12 at 15:28













0












0








0








This question already has an answer here:



  • Excel VBA: Enabling Macro Settings

    4 answers



I would like to know, whether it is possible to force the users of my sheet, to enable macros before using.



And having my macro put on hold, before they say "OK" to enabling macros.



Thank you in advance :)










share|improve this question














This question already has an answer here:



  • Excel VBA: Enabling Macro Settings

    4 answers



I would like to know, whether it is possible to force the users of my sheet, to enable macros before using.



And having my macro put on hold, before they say "OK" to enabling macros.



Thank you in advance :)





This question already has an answer here:



  • Excel VBA: Enabling Macro Settings

    4 answers







excel vba excel-vba






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 12 at 15:12









Patrick S

526




526




marked as duplicate by Darren Bartrup-Cook, cyboashu, Wizhi, Billal Begueradj, lagom Nov 13 at 5:28


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






marked as duplicate by Darren Bartrup-Cook, cyboashu, Wizhi, Billal Begueradj, lagom Nov 13 at 5:28


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









  • 2




    If there were an answer to this, the would be a hole in macro security big enough to drive a truck through.
    – Comintern
    Nov 12 at 15:15










  • Your macro doesn't need to be put on hold because it won't be running until the user clicks "OK" to enabling macros. There is no way with a macro to overwrite this though as that's the entire point of excel prompting the user to enable them for the workbook. If you need that level of control on the user's machine, then a Macro is not the way to go. You could use VSTO and/or Excel Interop in C#/Visual Studio though to write up a workbook that acts more like a traditional application on the users machine. Bit of a learning curve there though.
    – JNevill
    Nov 12 at 15:15











  • Well, my Macro from “Private sub Workbook Open()” doesn’t run upon opening, and not after allowing macros.
    – Patrick S
    Nov 12 at 15:19






  • 1




    Is the question whether it's possible to force users to enable macros or why your Workbook_Open event isn't firing?
    – Darren Bartrup-Cook
    Nov 12 at 15:23






  • 1




    Well, would prefer to force them to accept first, but seemed as if that wasn’t possivble. So if I can get a solution for Workbook_Open, it’ll do the trick :)
    – Patrick S
    Nov 12 at 15:28












  • 2




    If there were an answer to this, the would be a hole in macro security big enough to drive a truck through.
    – Comintern
    Nov 12 at 15:15










  • Your macro doesn't need to be put on hold because it won't be running until the user clicks "OK" to enabling macros. There is no way with a macro to overwrite this though as that's the entire point of excel prompting the user to enable them for the workbook. If you need that level of control on the user's machine, then a Macro is not the way to go. You could use VSTO and/or Excel Interop in C#/Visual Studio though to write up a workbook that acts more like a traditional application on the users machine. Bit of a learning curve there though.
    – JNevill
    Nov 12 at 15:15











  • Well, my Macro from “Private sub Workbook Open()” doesn’t run upon opening, and not after allowing macros.
    – Patrick S
    Nov 12 at 15:19






  • 1




    Is the question whether it's possible to force users to enable macros or why your Workbook_Open event isn't firing?
    – Darren Bartrup-Cook
    Nov 12 at 15:23






  • 1




    Well, would prefer to force them to accept first, but seemed as if that wasn’t possivble. So if I can get a solution for Workbook_Open, it’ll do the trick :)
    – Patrick S
    Nov 12 at 15:28







2




2




If there were an answer to this, the would be a hole in macro security big enough to drive a truck through.
– Comintern
Nov 12 at 15:15




If there were an answer to this, the would be a hole in macro security big enough to drive a truck through.
– Comintern
Nov 12 at 15:15












Your macro doesn't need to be put on hold because it won't be running until the user clicks "OK" to enabling macros. There is no way with a macro to overwrite this though as that's the entire point of excel prompting the user to enable them for the workbook. If you need that level of control on the user's machine, then a Macro is not the way to go. You could use VSTO and/or Excel Interop in C#/Visual Studio though to write up a workbook that acts more like a traditional application on the users machine. Bit of a learning curve there though.
– JNevill
Nov 12 at 15:15





Your macro doesn't need to be put on hold because it won't be running until the user clicks "OK" to enabling macros. There is no way with a macro to overwrite this though as that's the entire point of excel prompting the user to enable them for the workbook. If you need that level of control on the user's machine, then a Macro is not the way to go. You could use VSTO and/or Excel Interop in C#/Visual Studio though to write up a workbook that acts more like a traditional application on the users machine. Bit of a learning curve there though.
– JNevill
Nov 12 at 15:15













Well, my Macro from “Private sub Workbook Open()” doesn’t run upon opening, and not after allowing macros.
– Patrick S
Nov 12 at 15:19




Well, my Macro from “Private sub Workbook Open()” doesn’t run upon opening, and not after allowing macros.
– Patrick S
Nov 12 at 15:19




1




1




Is the question whether it's possible to force users to enable macros or why your Workbook_Open event isn't firing?
– Darren Bartrup-Cook
Nov 12 at 15:23




Is the question whether it's possible to force users to enable macros or why your Workbook_Open event isn't firing?
– Darren Bartrup-Cook
Nov 12 at 15:23




1




1




Well, would prefer to force them to accept first, but seemed as if that wasn’t possivble. So if I can get a solution for Workbook_Open, it’ll do the trick :)
– Patrick S
Nov 12 at 15:28




Well, would prefer to force them to accept first, but seemed as if that wasn’t possivble. So if I can get a solution for Workbook_Open, it’ll do the trick :)
– Patrick S
Nov 12 at 15:28












1 Answer
1






active

oldest

votes


















6














If your goal is to have the user enable macros so that your code runs, then there is a non technical solution to it.



When opening the workbook, have all Worksheets set to xlVeryHidden except for one which is visible. On that visible sheet, inform the user that he must enable macros in able to use the workbook.



Once macros are enabled, have code that runs on the Workbook_open event and unhides the needed worksheets and hides the one worksheet that would be shown if macros are not enabled.






share|improve this answer


















  • 3




    Creative... nice
    – Kubie
    Nov 12 at 15:28






  • 3




    I did pretty much exactly that in this project - and have implemented many variants of it throughout the years: +1 from me, that's the best way to go about it IMO.
    – Mathieu Guindon
    Nov 12 at 15:31







  • 1




    Thanks. I have also found it to be the most reliable workaround when sending macros workbooks to customers whose systems i don't know.
    – rohrl77
    Nov 12 at 15:33










  • Are you able to assign a macro to “whenever macro is enabled”?
    – Patrick S
    Nov 12 at 16:01










  • @PatrickS The Workbook_Open() event is triggered immediately upon the workbook opening up. It comes before almost anything else. Infact, I'm not sure that there is anything prior, so I think it's the closest thing to what you are asking for.
    – rohrl77
    Nov 12 at 20:32

















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









6














If your goal is to have the user enable macros so that your code runs, then there is a non technical solution to it.



When opening the workbook, have all Worksheets set to xlVeryHidden except for one which is visible. On that visible sheet, inform the user that he must enable macros in able to use the workbook.



Once macros are enabled, have code that runs on the Workbook_open event and unhides the needed worksheets and hides the one worksheet that would be shown if macros are not enabled.






share|improve this answer


















  • 3




    Creative... nice
    – Kubie
    Nov 12 at 15:28






  • 3




    I did pretty much exactly that in this project - and have implemented many variants of it throughout the years: +1 from me, that's the best way to go about it IMO.
    – Mathieu Guindon
    Nov 12 at 15:31







  • 1




    Thanks. I have also found it to be the most reliable workaround when sending macros workbooks to customers whose systems i don't know.
    – rohrl77
    Nov 12 at 15:33










  • Are you able to assign a macro to “whenever macro is enabled”?
    – Patrick S
    Nov 12 at 16:01










  • @PatrickS The Workbook_Open() event is triggered immediately upon the workbook opening up. It comes before almost anything else. Infact, I'm not sure that there is anything prior, so I think it's the closest thing to what you are asking for.
    – rohrl77
    Nov 12 at 20:32















6














If your goal is to have the user enable macros so that your code runs, then there is a non technical solution to it.



When opening the workbook, have all Worksheets set to xlVeryHidden except for one which is visible. On that visible sheet, inform the user that he must enable macros in able to use the workbook.



Once macros are enabled, have code that runs on the Workbook_open event and unhides the needed worksheets and hides the one worksheet that would be shown if macros are not enabled.






share|improve this answer


















  • 3




    Creative... nice
    – Kubie
    Nov 12 at 15:28






  • 3




    I did pretty much exactly that in this project - and have implemented many variants of it throughout the years: +1 from me, that's the best way to go about it IMO.
    – Mathieu Guindon
    Nov 12 at 15:31







  • 1




    Thanks. I have also found it to be the most reliable workaround when sending macros workbooks to customers whose systems i don't know.
    – rohrl77
    Nov 12 at 15:33










  • Are you able to assign a macro to “whenever macro is enabled”?
    – Patrick S
    Nov 12 at 16:01










  • @PatrickS The Workbook_Open() event is triggered immediately upon the workbook opening up. It comes before almost anything else. Infact, I'm not sure that there is anything prior, so I think it's the closest thing to what you are asking for.
    – rohrl77
    Nov 12 at 20:32













6












6








6






If your goal is to have the user enable macros so that your code runs, then there is a non technical solution to it.



When opening the workbook, have all Worksheets set to xlVeryHidden except for one which is visible. On that visible sheet, inform the user that he must enable macros in able to use the workbook.



Once macros are enabled, have code that runs on the Workbook_open event and unhides the needed worksheets and hides the one worksheet that would be shown if macros are not enabled.






share|improve this answer














If your goal is to have the user enable macros so that your code runs, then there is a non technical solution to it.



When opening the workbook, have all Worksheets set to xlVeryHidden except for one which is visible. On that visible sheet, inform the user that he must enable macros in able to use the workbook.



Once macros are enabled, have code that runs on the Workbook_open event and unhides the needed worksheets and hides the one worksheet that would be shown if macros are not enabled.







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 12 at 15:30

























answered Nov 12 at 15:27









rohrl77

1,68942749




1,68942749







  • 3




    Creative... nice
    – Kubie
    Nov 12 at 15:28






  • 3




    I did pretty much exactly that in this project - and have implemented many variants of it throughout the years: +1 from me, that's the best way to go about it IMO.
    – Mathieu Guindon
    Nov 12 at 15:31







  • 1




    Thanks. I have also found it to be the most reliable workaround when sending macros workbooks to customers whose systems i don't know.
    – rohrl77
    Nov 12 at 15:33










  • Are you able to assign a macro to “whenever macro is enabled”?
    – Patrick S
    Nov 12 at 16:01










  • @PatrickS The Workbook_Open() event is triggered immediately upon the workbook opening up. It comes before almost anything else. Infact, I'm not sure that there is anything prior, so I think it's the closest thing to what you are asking for.
    – rohrl77
    Nov 12 at 20:32












  • 3




    Creative... nice
    – Kubie
    Nov 12 at 15:28






  • 3




    I did pretty much exactly that in this project - and have implemented many variants of it throughout the years: +1 from me, that's the best way to go about it IMO.
    – Mathieu Guindon
    Nov 12 at 15:31







  • 1




    Thanks. I have also found it to be the most reliable workaround when sending macros workbooks to customers whose systems i don't know.
    – rohrl77
    Nov 12 at 15:33










  • Are you able to assign a macro to “whenever macro is enabled”?
    – Patrick S
    Nov 12 at 16:01










  • @PatrickS The Workbook_Open() event is triggered immediately upon the workbook opening up. It comes before almost anything else. Infact, I'm not sure that there is anything prior, so I think it's the closest thing to what you are asking for.
    – rohrl77
    Nov 12 at 20:32







3




3




Creative... nice
– Kubie
Nov 12 at 15:28




Creative... nice
– Kubie
Nov 12 at 15:28




3




3




I did pretty much exactly that in this project - and have implemented many variants of it throughout the years: +1 from me, that's the best way to go about it IMO.
– Mathieu Guindon
Nov 12 at 15:31





I did pretty much exactly that in this project - and have implemented many variants of it throughout the years: +1 from me, that's the best way to go about it IMO.
– Mathieu Guindon
Nov 12 at 15:31





1




1




Thanks. I have also found it to be the most reliable workaround when sending macros workbooks to customers whose systems i don't know.
– rohrl77
Nov 12 at 15:33




Thanks. I have also found it to be the most reliable workaround when sending macros workbooks to customers whose systems i don't know.
– rohrl77
Nov 12 at 15:33












Are you able to assign a macro to “whenever macro is enabled”?
– Patrick S
Nov 12 at 16:01




Are you able to assign a macro to “whenever macro is enabled”?
– Patrick S
Nov 12 at 16:01












@PatrickS The Workbook_Open() event is triggered immediately upon the workbook opening up. It comes before almost anything else. Infact, I'm not sure that there is anything prior, so I think it's the closest thing to what you are asking for.
– rohrl77
Nov 12 at 20:32




@PatrickS The Workbook_Open() event is triggered immediately upon the workbook opening up. It comes before almost anything else. Infact, I'm not sure that there is anything prior, so I think it's the closest thing to what you are asking for.
– rohrl77
Nov 12 at 20:32



這個網誌中的熱門文章

How to read a connectionString WITH PROVIDER in .NET Core?

Node.js Script on GitHub Pages or Amazon S3

Museum of Modern and Contemporary Art of Trento and Rovereto