You are not logged in.

Dear visitor, welcome to Palo Community Forum. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

  • "a_malinowski" is male
  • "a_malinowski" started this thread

Posts: 72

Date of registration: Nov 12th 2008

Location: Berlin, Germany

  • Send private message

1

Friday, December 23rd 2011, 12:56pm

Enable connection to palo server via VBA

Hi,

I have written a function which allows me to enable an existing but closed connection to a palo server.

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
Private Function ConnectToPaloServer(server As String) As Boolean

    Dim retval As Variant
    Dim connectionStatus As Variant
    Dim connectionInfo As Variant
    Dim nextTry As Boolean
    Dim success As Boolean

    Dim obj As Jedox_Palo_XlAddin.IPaloEngineCom
    Set obj = New Jedox_Palo_XlAddin.ComInterface

    On Error GoTo ConnectToPaloServer_Error

    'ggf. Verbindung auf "online" stellen
    retval = RegValueGet(HKEY_CURRENT_USER, RegKey & server & "\", "connected", connectionStatus)
    If connectionStatus <> "true" Then _
        retval = RegValueSet(HKEY_CURRENT_USER, RegKey & server & "\", "connected", "true")

    obj.ForceServerListUpdate

    On Error Resume Next
    Do
        success = False
        nextTry = False
        connectionInfo = obj.GetConnectionDataInfo(server)

        Select Case Err.Number
            Case 0:
                If connectionInfo(0) = "" Then
                    success = True
                    nextTry = False
                Else
                    retval = MsgBox(connectionInfo(0), vbAbortRetryIgnore)
                    nextTry = (retval = vbRetry)
                End If
            Case Else:
                retval = MsgBox("Anmeldung am Palo Server fehlgeschlagen.", vbAbortRetryIgnore)
                nextTry = (retval = vbRetry)
        End Select
        Err.Clear
        
    Loop While nextTry

    ConnectToPaloServer = success

    On Error GoTo 0
    Exit Function

ConnectToPaloServer_Error:

    Debug.Print "Error " & Err.Number & " (" & Err.Description & ") in procedure ConnectToPaloServer of Modul PaloServerRegistration"

    ConnectToPaloServer = False

End Function

The trick is very simple. Jedox saves all informations about server connections in registry. You can manipulate every entry such as "connected". Afterwards you have to force palo to requery registry. This should do the the method ForeceServerListUpdate. But in some cases palo doesn't recongnize the changes. A Palo.Data formula ends in an error and modeller doesn't show the entry.

Has anybody else notice such a behavior?

Regards

Andreas

P.S.: As a christmas gift I provide you my whole VBA module with other usefull functions about palo connections :)
a_malinowski has attached the following file:
Andreas Malinowski
FORECAST Unternehmensplanungen GmbH, Berlin, Germany
www.forecast.de

Rate this thread