Force Users to Enable Macros in a Workbook

ChristianPetersen

New Member
Joined
Nov 8, 2017
Messages
8
I am sorry, if this already has a thread. It is the first time I am logged on to MREXCEL.com. I have previously found MREXCEL VERY useful. Now to my question (sorry for my poor English):

I would like to "Force Users to Enable Macros in a Workbook". I have seen solutions to this problem on many sites, including this one. However, it seems to me that to work the user must accept macros, otherwise how can the macro run that forces the user to accept macros. Put differently, if the user just ignore 'accept macros' and save the file in the usual XLSX format, he or she can use the spreadsheet without macros?

The reason why, I need users to enable macros is quite simply that the spreadsheet is only valid for a specific period of time, and then closes down. However, if the user disregard macros they can continue using the spreadsheet for ever (which is a long time :)).

I appreciate any help on the issue.

Best regards
Christian
 
One final question. It works except for the fact that the user should be able to save the file as an XLSM file and rename it, but not save it as an XLSX file.
Your help is highly appreciated. I learn a little every time :).
 
Upvote 0

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
In that case, how about
Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)

    If SaveAsUI Then
        Cancel = True
    
        txtFileName = Application.GetSaveAsFilename(, "Excel Macro-Enabled Workbook (*.xlsm), *.xlsm", , "Save As XLSM file")
         If txtFileName = "False" Then
             MsgBox "Action Cancelled", vbOKOnly
             Cancel = True
             Exit Sub
         End If
    
         Application.EnableEvents = False
         ThisWorkbook.SaveAs Filename:=txtFileName, FileFormat:=52
         Application.EnableEvents = True
        
     End If

End Sub
 
Upvote 0
I will give it a try. Once again thank you for helping me out. I am probably going to ask more questions in the future, so maybe we will 'meet' again :).
Roger over and out...
 
Upvote 0

Forum statistics

Threads
1,214,643
Messages
6,120,702
Members
448,980
Latest member
CarlosWin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top