# Edit Module

Macros and custom defined functions can be written in VBScript or JScript using the Edit Module dialog. The module is saved with the document.

The following commands are available:

From the File menu the Export to Module File command lets you save the script as a file. There is also an option to Print the script.

The Edit menu contains a number of common options: Undo, Redo, Copy, Cut, Paste, Clear, Select All and Find/Replace. There is also an option: Insert File which permits you to import a previously saved Script File. Transform any text row in the script into a comment by means of the Comment command and switch it back again by using Uncomment.

Edit Module properties

| Property | Description |
| --- | --- |
| (Macro Edit<br>Box) | The large edit box is where you type your<br>macros. All macros should be written as sub-routines between a matching<br>pair of `sub  .. end  sub`. |
| (List of<br>entry points) | As soon as an entry point is recognized by<br>the scripting engine, it will appear in the list in the smaller, left<br>text box. It is also possible to select entry points from this list. |
| (Message) | The current state of any error messages is<br>displayed in the box above the macro edit box. |
| Check | Once you have a written sub, check<br>and validate its syntax by pressing this button. |
| Goto | Highlighting an entry point from the List of entry points and clicking Goto, takes you directly to its position<br>in the Macro Edit Box. |
| Test | With an entry point selected, you may test<br>a macro by clicking the Test button. Any errors will appear in the Message<br>box. |
| Scripting<br>Engine | Select between VBScript and JScript. |
| Requested<br>Module Security | By selecting Safe Mode the document<br>designer indicates that the macros in this QlikView document contain no<br>code that can access either the system or applications outside QlikView.<br>If such code is encountered during macro execution in a document declared<br>to be in Safe Mode, the execution<br>will fail.<br><br>By selecting System<br>Access mode the document designer ensures that the end user will<br>be prompted when opening the document to either approve system access<br>(Allow System Access), disable<br>all macros in the document (Disable Macros)<br>or allow only macros without system access (Safe<br>Mode). |
| Current Local<br>Security | When opening a document declared to be in<br>safe mode but containing potentially "unsafe" macro code, the<br>user will be prompted (see Requested<br>Module Security above). The user's action will be remembered by<br>the system but this setting can be changed at a later time from this menu.<br>Macro security level can be set to Don't<br>Run at All, Only Safe Mode or Allow System Access. |

[Internal Macro Interpreter](https://help.qlik.com/en-US/qlikview/May2024/Subsystems/Client/Content/QV_QlikView/Internal_Macro_Interpreter.htm)

Information noteThis is just a very brief introduction to the QlikView Scripting Engine. For a deeper understanding of VBScript or JScript you should refer to a handbook on the subject.