Professional Documents
Culture Documents
Aison
BSA-4
Auditing in the IT Environment
1. What is Visual Basic for Application?
Visual Basic for Applications is a programming that is similar to Visual Basic, only it is
embedded in an individual Microsoft application such as Excel or Access. Using VBA you can
create macros or small programs that perform tasks within the Microsoft application.
2. What is Macros?
Enable macros for one time when the Security Warning appears
Use the following instructions to enable macros for the duration that the file is open. When you
close the file, and then reopen it, the warning appears again.
Click the File tab.
In the Security Warning area, click Enable Content.
Select Advanced Options.
In the Microsoft Office Security Options dialog box, click Enable content for this
session for each macro.
Click OK.
Change macro settings in the Trust Center
Macro settings are located in the Trust Center. However, if you work in an organization, the
system administrator might have changed the default settings to prevent anyone from
changing settings.
IMPORTANT When you change your macro settings in the Trust Center, they are changed
only for the Office program that you are currently using. The macro settings are not changed
for all your Office programs.
Click the File tab.
Click Options.
Click Trust Center, and then click Trust Center Settings.
In the Trust Center, click Macro Settings.
Make the selections that you want.
Click OK.
The following image is the Macro Settings area of the Trust Center.
3. On the Protection tab, check "Lock project for viewing" and enter a password twice.
4. Click OK.
5. Save, close and reopen
You can still execute the code by clicking on the command button but you cannot view or edit the code anymore
(unless you know the password). The password for the downloadable Excel file is "easy".
6. If you want to password protect the macro from being executed, add the following code lines:
Dim password As Variant
password = Application.InputBox("Enter Password", "Password Protected")
Select Case password
Case Is = False
'do nothing
Case Is = "easy"
Range("A1").Value = "This is secret code"
Case Else
MsgBox "Incorrect Password"
End Select
Result when you click the command button on the sheet:
Explanation: The macro uses the InputBox method of the Application object. If the users clicks Cancel, this
method returns False and nothing happens (InputBox disappears). Only when the user knows the password
("easy" again), the secret code will be executed. If the entered password is incorrect, a MsgBox is displayed.
Note that the user cannot take a look at the password in the Visual Basic Editor because the project is protected
from being viewed.