Results 1 to 6 of 6

Thread: Public (2003)

  1. #1
    Star Lounger
    Join Date
    Feb 2001
    Location
    Virginia Beach, Virginia, USA
    Posts
    80
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Public (2003)

    I have a .xla with a global module for hold all my global constants (surprise)
    If I declare some of the constants as Public should they be available to other spreadsheets that reference the .XLA? My documentation says public are available to all applications and projects but that doesn't seem to be the case. Any advise?

    Thanks
    David

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Public (2003)

    Normally, public variables are public to the project ("workbook") in which they are defined. You can make them available in another workbook:

    1) Open your .xla
    Activate the Visual Basic Editor.
    Click on the name of the .xla in the Project Explorer.
    Set a unique name for the (Name) of the project in the Properties pane. (Default is the generic name VBAProject).
    Save the .xla.

    2) Open or create a workbook in which you want to use a variable from the .xla.
    Activate the Visual Basic Editor.
    Select Tools | References...
    Set a reference to the project name that you defined in step 1.
    Click OK.

    You can now use the public procedures, functions, variables and constants from the .xla.

  3. #3
    Star Lounger
    Join Date
    Feb 2001
    Location
    Virginia Beach, Virginia, USA
    Posts
    80
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Public (2003)

    Thanks.
    Still no luck on the public constants.
    xla project is named (vbaCBBT)
    The spreadsheet references the xla (Shows up in reference dialog and in the project folder references.
    I can call the various public functions and subs included in the xla. However the project will not compile; stopping on the first constant with a 'variable undefined' error.

    Could this be caused by the fact that there used to be a variable of the same name in the spreadsheet but it is now in the XLA?

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Public (2003)

    Let's say your constant is named clngTest. Try referring to it as vbaCBBT.clngTest

  5. #5
    Star Lounger
    Join Date
    Feb 2001
    Location
    Virginia Beach, Virginia, USA
    Posts
    80
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Public (2003)

    Thanks Hans, that is a great idea.
    However, it did not solve the problem. It did produce some interesting results thought.
    A list of of the available procedure/function/object in vbaCBBT (created by vbaCBBT. ) shows some of what should be available and none from the mGlobals module. Interestingly, while the functions in mGlobals do not appear in the lists, they can be called from the other project.

    Confusing. I will probably export and rebuild. It seems to help sometimes. But I would welcome any other imparted wisdom.

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Public (2003)

    If you wish, you can attach a zipped copy of your add-in, so that Loungers can investigate the problem directly.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •