Declare a Public Variant as constant

58 views Asked by At

I am having trouble assigning a value to constant variant declaration. So the declaration is this

Option Explicit
public const Abc as variant = ?

Abc is a Microfocus rumba object which gets initiated when the workbook is open, something like this

sub workbook_open()
   Set Abc= session.GetRDEObject()
End sub

But I cannot use this to assign it to the const variable, it says "Circular dependencies". The reason I am wanting to assign value is to ensure the object Abc is alive even after user executes End statement. Is there a way I can do this?.

I have tried creating a separate function and adding its return value to the Abc, but it does not work.

1

There are 1 answers

2
Gustav On

A constant is exactly that, so try something like this:

Option Explicit
Private Abc As Object

Private Sub Workbook_Open()
   Set Abc = Session.GetRDEObject()
End sub

Public Function GetAbc() As Object
    Set GetAbc = Abc
End Function