connectSpec {function}

 

 

Example of an Excel VBA application using the connectSpec function:

 

 

 

'Global variables

Global addIn As COMAddIn

Global mooAutoObj As Object

Global retboo As String

 

 

'A simple example of a Sub written in VBA in Excel Connecting to Oracle OLAP

'This example:

'  1) Checks that the moo library is installed.

'  2) Attempts to connects to Oracle OLAP

'  3) If it is connected then retrieves the value of seconds from Oracle OLAP

'  4) Disconnects.

 

 

Sub mooExample()

 

  Dim hostname  As String

  Dim sid As String

  Dim port As String

  Dim username As String

  Dim password As String

 

  'This is used to ensure that Excel has registered the MooXL library.

  If addIn Is Nothing Then

           Set addIn = Application.COMAddIns("MooXL")

           Set mooAutoObj = addIn.Object

                      End If

 

  'Populate your environment specific connection information

  hostname = "yourOracleServerHostName"

  sid      = "yourOracleServerSid"

  port     = "1522"                              'This should be the port of your Oracle Database

  username = "yourUsername"

  password = "yourPassword"

 

  Call mooAutoObj.connectspec(hostname, sid, port, username, password)  'Attempt to Connect 

 

  If mooAutoObj.connected() Then          'Check if we connected ok

     Debug.Print mooAutoObj.mooSeconds    'Print the value of seconds to the immediate window

  ELSE

     Debug.print “Unable to Connect”

  End If

 

  retboo = mooAutoObj.disconnect     'Disconnect

 

  If retboo then

    Debug.print “Disconnected ok”

  End if

 

End Sub

 

 

The myObjectiveOLAP connectSpec function can be incorporated into a client VBA application. Unlike connect full connection information is supplied when calling the connectSpec function.

 

connectSpec does not attempt to use any settings.xml saved connection files

Microsoft®, WINDOWS®, Microsoft Excel®, Microsoft Office® are registered trademarks of Microsoft Corporation.

ORACLE® is a registered trademark of ORACLE Corporation.

® SDMC Consulting Limited 2010