Hi Xin,
we use some VBA in our input forms.
- as first you need to do 2 things:
open developer(alt+F11)/ Tools references/ enable it
![fmpxlm.jpg]()
in module declare epm functionalities:
Public EPM_function As New FPMXLClient.EPMAddInAutomation
- you need to know these events, so you can run your code when it is needed:
before_contextchange
after_contextchange
before_refresh
after_refresh
before_save
after_save
- usually declared as functions (if there is a need to stop it with FALSE in case you want to abort)
- then very important is to identify report position within a sheet using epm functionalities:
- as example below, all variables are integers
top_report_cellRow1 = Range(EPM_function.GetDataTopLeftCell(ActiveSheet, "001")).Row
top_report_cellCol1 = Range(EPM_function.GetDataTopLeftCell(ActiveSheet, "001")).Column
bottom_report_cellRow1 = Range(EPM_function.GetDataBottomRightCell(ActiveSheet, "001")).Row
bottom_report_cellCol1 = Range(EPM_function.GetDataBottomRightCell(ActiveSheet, "001")).Column
- very important is to faster your code using:
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
Application.EnableEvents = False
- then you can control when and where is VBA code executed.
For example:
you can control what user has selected in after_contextchange
you can control what is user saving in before_save
you can do silent refresh and save
you can even control user options, run packages using VBA and lot more.
tomas.