Results 1 to 5 of 5
  1. #1
    3 Star Lounger
    Join Date
    Feb 2003
    Posts
    363
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Passing a variable to another workbook (2000)

    I'm running code in one workbook and want to change the value of a global variable in another wbk (an addin, in this case). What is the syntax?

    something like:

    Workbooks("MyAddin").Name("gsMyGlobal")="Hello"

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

    Re: Passing a variable to another workbook (2000)

    The scope of a global variable is the project (workbook) in which it is defined. It is not know, and therefore can not be set from another workbook. You would have to create code in the workbook where the variable is defined that sets the variable value, then call that code from the other workbook.
    Legare Coleman

  3. #3
    3 Star Lounger
    Join Date
    Feb 2003
    Posts
    363
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Passing a variable to another workbook (2000)

    So perhaps a workaround like:

    Wbk A
    gsMyglobal = Sheet1.range("A1").value

    Code in WbkB
    Workbooks(WbkA).Sh1.Range("A1")="Hello"

    would work ????

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

    Re: Passing a variable to another workbook (2000)

    That should work.

    You can also set a reference to the other workbook in Tools | References. You can then use public variables, constants, functions and procedures from that workbook.

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

    Re: Passing a variable to another workbook (2000)

    OOPS! I didn't realize that setting a reference to the workbook (addin) would expose public variables. I thought it just exposed the procedure names.
    Legare Coleman

Posting Permissions

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