Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    NJ, USA
    Posts
    239
    Thanks
    2
    Thanked 1 Time in 1 Post

    Accessing VB variables in another workbook (2003, SP1)

    I have two workbooks open. One of them has a global VB variable (gblnAccess) that I am trying to access from the other workbook. I've tried a number of different ways of referencing it, but no luck. Does anybody know what the syntax would be? The parent should be the project, I assume, but I can't get it to work.
    TIA

  2. #2
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Accessing VB variables in another workbook (2003, SP1)

    VBA variables can not be accessed outside the project in which they are defined. If you must access data accross projects, that data would have to be stored in a place like a cell in a worksheet, or in the Resistry, or in a .txt file, or some other such place.
    Legare Coleman

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

    Re: Accessing VB variables in another workbook (2003, SP1)

    Apart from Legare's remarks, you could:
    - Give the VBAProject for the workbook in which gblnAccess is defined a unique name, for example MyProject.
    - Set a reference (Tools | References...) in the other workbook to MyProject.
    - You can now use gblnAccess or MyProject.gblnAccess (to avoid ambiguity).
    But setting a reference may not be attractive - that's up to you to decide.

  4. #4
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    NJ, USA
    Posts
    239
    Thanks
    2
    Thanked 1 Time in 1 Post

    Re: Accessing VB variables in another workbook (2003, SP1)

    Thanks to both of you. If I had to guess who would know the answer and respond, you two would have been at the top of the list!

Posting Permissions

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