AnsweredAssumed Answered

Processbook: Avoid processbook go to current time when context change programatically

Question asked by PedroCampos on Apr 26, 2019
Latest reply on Jul 22, 2019 by PedroCampos

Hello Everyone!


I have created an processbook display with Relative template, but I have one menu with buttons with all interest elements at the same page. I have created a macro to change the context of my processbook when I click over one of my elements.


The problem is when I am at a period on the past and click on the button to change the context. First of all the page go to current time and load al the values and trend to current time and then back to the period there I have chosen. I wold like to avoid this load to current time when I am in the past time.


Here is the code:



Option Explicit
'- Altera o contexto da tela de acordo com o elemento selecionado
Sub changeContext()

    Dim pbButtons As Object
    Dim buttonName As String
    Set pbButtons = ThisDisplay.SelectedSymbols(1)
    Dim elementName As String
    Dim buttonNameArray() As String
    Dim path As String
    buttonName = pbButtons.GetTagName(1)
    buttonNameArray = Split(buttonName, "|")
    path = Replace(buttonNameArray(0), "AF2.\\", "\\")
    Dim sContext As String
    Dim mERDContext As ContextHandler
    Dim mDatabasePath As String
    Set mERDContext = Application.ContextHandlers("E")
    sContext = path
    mERDContext.CurrentContext(ThisDisplay) = sContext
End Sub