Initializing Modules

 

Introduction

A VBA (Visual Basic for Applications) module can implement an initializing function which will be executed by RC-WinTrans each time the VBA project (the macros file) is initialized to be used in the VBA system.  This is typically at the time when RC-WinTrans is started up.  The function is also called when the corresponding macros file is added to RC-WinTrans using the Add Macros File command.

 

A terminating procedure can be implemented to supplement the initializing function.

 

NOTE: When you create a new macros file you can opt to create it with a module in which a macro-initializing and a macro-finalizing function are already implemented.

 

 

Implementation

Initializing a module is useful for enabling, creating, or loading something to make it available immediately after RC-WinTrans is started.

 

Some examples of how an initializing function can be used include:

initializing an event handler class

loading a DLL, as in a DLL that implements and registers windows classes used by files to be translated, and where the windows classes are required to display customized dialog box controls properly in RC-WinTrans' Dialog Box Editor.

 

NOTE: Each module can implement an initializing function (one time).  The function will be called for each module.

 

 

"OnInitModule" Function

This function is called after RC-WinTrans has been started and the VBA system is running.

 

Function OnInitModule() As Boolean

  On Error GoTo ErrHdl

 

  ' Your Code  '  < e.g.load a DLL or initialize an event handler class

 

  OnInitModule = True

  Exit Function

 

ErrHdl:

    'Error handling

    OnInitModule = False

End Function

 

 

"OnTerminate" Procedure

This procedure is called before RC-WinTrans is closed or when a macros file is going to be removed from the VBA system.

 

Sub OnTerminateModule()

  On Error GoTo ErrHdl

 

   ' Your Code  '

 

  Exit Sub

  ErrHdl:

   ' Error handling

End Sub

 

NOTE: An "OnTerminateModule" procedure can be implemented for each module.

 

 

Example

For a sample implementation of a module-initializing function and a supporting terminating procedure used to create a new macros file with RC-WinTrans, open the Macros Files dialog box (Tools menu | Macros Files command) and select the template file "With module initializing procedures."

 

 

^ Top ^