Automatic procedures using VBA
Exsion has the ability to perform your own VBA procedures before or after the data refresh. Furthermore, it is also possible the other way around to perform the "Refresh data" function from within the own procedure. Keep in mind that errors that occur within your own procedure can affect the operation of Exsion. In case of problems, always test first whether the error also occurs with standard use of Exsion, without own procedures.
Call from your own procedure
The Refresh data function can be called from your own VBA procedure. Where you want to refresh the data in your own procedure, add the following line in the code via the VBA editor (ALT-F11):
Application.Run "Exsion.xlam!MENU_DATA"
Executing this line has exactly the same effect as pressing the "Refresh data" button in the Exsion menu. This way you can also call the Formulas to values menu option:
Application.Run "Exsion.xlam!MENU_VALUES"
To bypass Exsion’s warning message box use the following:
Dim s_displayAlertsSetting As Boolean s_displayAlertsSetting = Application.DisplayAlerts Application.DisplayAlerts = False On Local Error Resume Next Application.Run "Exsion.xlam!MENU_VALUES" On Local Error GoTo 0 Application.DisplayAlerts = s_displayAlertsSetting
Data refresh execution procedure
It is possible to perform a procedure just before the data refresh. To do this, include the following code in a module. Instead of [Own procedure name], enter the name of the procedure you want to perform. This procedure must be present in the same project.
Sub Exsion_beforerefresh() Call [Own procedure name] End Sub
To abort the Data refresh procedure you can exit your own procedure after entering this line:
Err.Source = "exsion_cancel"
Execute procedure after data refresh
In addition to performing a procedure just before the data refresh, it is also possible to perform a precedure right after the data refresh. To do this, include the following code in a module. Instead of [Own procedure name], enter the name of the procedure you want to perform. This procedure must be present in the same project.
Sub Exsion_onrefresh() Call [Own procedure name] End Sub
Example for a Refresh after cell change
Place this macro in the ThisWorkbook section.
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range) If Target = ActiveSheet.Range("Subcategory") Then Application.Run "'Exsion.xlam'!MENU_DATA" ActiveSheet.Calculate End If End Sub
©HB Software B.V.