Page 1 of 1

VBA N_Connect

Posted: Fri Sep 13, 2013 2:38 pm
by AmbPin
Hello,
Regarding the simple code extract below:-

Code: Select all

  Dim s As String
    
  s = Application.Run("N_CONNECT", sTM1Server, "UID", "PWD")
  If s = "" Then
    Debug.Print Application.Run("DimSiz", "TM1Server" & ":}Clients")
    Debug.Print Application.Run("DIMNM", "MyServer:}Clients", 1, "Alias")
    Debug.Print Application.Run("N_DISCONNECT")
  End If
This works fine the first time I run it, however the DimNM function returns blank on every subsequent run. Is this to be expected?

Re: VBA N_Connect

Posted: Fri Sep 13, 2013 2:42 pm
by AmbPin
Just added a call to TM1Refresh as shown below:-

Code: Select all

  Dim s As String
    
  s = Application.Run("N_CONNECT", sTM1Server, "UID", "PWD")
  If s = "" Then
    Application.Run "TM1Refresh"
    Debug.Print Application.Run("DimSiz", "TM1Server" & ":}Clients")
    Debug.Print Application.Run("DIMNM", "MyServer:}Clients", 1, "Alias")
    Debug.Print Application.Run("N_DISCONNECT")
  End If
Which now makes it work OK. Is the the best way to do this?