I am trying to copy two different operations into a "This workbook". One is the "disable cut copy paste" function that I found and the other is the "force user to enable macros" so that the disable cut copy paste function will automatically run. However, I get an error message when I put in both of these functions. How can I run two different functions simultaneously in the "This workbook" area? I hope I have explained this sufficiently. Thanks!
The articles we're referring to are:
- Disable Cut, Copy, Paste: http://www.vbaexpress.com/kb/getarticle.php?kb_id=373
- Force User To Enable Macros: http://www.excelguru.ca/node/91
Now, for users who are still learning, this can be a bit tricky. A couple of really important points to know when combining entries:
- There can only be one "Option Explicit" line, and it must be at the top of the module. (It can be below other "Option" lines, but to be safe just make it the first line.)
- There can only be one procedure in the module with any given name. I.e. you can't have two Workbook_Open routines.
So what that means is that we need to stitch our workbook_open code together. In this case the routine from "Force Users To Enable Macros" is longer, so we'll start with that one. The code from "Disable, Cut, Copy, Paste" is only one line, so we'll cut and paste that into the routine as follows:
Private Sub Workbook_Open()
'Author : Ken Puls (www.excelguru.ca)
'Macro Purpose: Unhide all worksheets since macros are enabled\Application.ScreenUpdating = False
Application.ScreenUpdating = True
ThisWorkbook.Saved = True
And that should be it.Â None of the other routines have conflicting names so, providing they are all placed in the appropriate modules things should work.