For example, I want to automatically delete an Excel form after March 2, 2013, and a macro called Macro1 in the table.
Specifically as follows:
Sub Macro1 ()
Private Sub Workbook_Open ()
Application.DisplayAlerts = False
Dim Datee as Date
Datee = #3/2/2013#
If Date > Datee Then
Activeworkbook.changefileaccess xlreadonly
Kill Activeworkbook.fullname
Thisworkbook.close False
End If
End Sub
But this macro cannot be executed, March 4, 2013 This Excel form has not been deleted! I am not the computer administrator, is the user this does not affect?
Delete the first sentence of the macro and turn it into:
Sub Workbook_Open ()
Application.DisplayAlerts = False
Dim Datee as Date
Datee = #3/2/2013#
If Date > Datee Then
Activeworkbook.changefileaccess xlreadonly
Kill Activeworkbook.fullname
Thisworkbook.close False
End If
End Sub
Then put the macros under the ThisWorkbook of Excel
What does the name of the macro take? What do I do when I finish typing? What macro name do you want to view the source code?
The macro name is Workbook_Open, a process built into Excel. Execute the macro when you open the file ...
If you open the date more than 3/2/2013, the file is deleted when it is opened.
You can copy this code into any empty file, test it, and remember not to put it in your important file to test.
See the Red Code press ALT+F8 can