Results 1 to 6 of 6
  1. #1
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Illinois
    Posts
    552
    Thanks
    0
    Thanked 1 Time in 1 Post

    Call a sub in an .xla from another file (Excel xp)

    I have an add-in called slo.xla in my startup folder. It is always available when i'm in excel. Now i'm writing a macro in a separate excel file called text.xls and would like to call a procedure from my slo.xla. Is that possible? thank you

  2. #2
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Call a sub in an .xla from another file (Excel xp)

    Try something like this in your code:

    <pre>Run "slo.xla!ProcedureName"</pre>


    Steve

  3. #3
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Illinois
    Posts
    552
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Call a sub in an .xla from another file (Excel xp)

    yep, that worked. Now i realize that the ProcedureName that i'm calling gets variables from a form in the slo.xla. I am dimensioning those variables in my new macro and have them as global variables at the top of the procedure. They are not passing to the slo.xla!ProcedureNames. How do i get my variable values to "pass" to the slo.xla!ProcedureName? thank you

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

    Re: Call a sub in an .xla from another file (Excel xp)

    The best way would be to pass them as parameters in the procedure call.
    Legare Coleman

  5. #5
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Illinois
    Posts
    552
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Call a sub in an .xla from another file (Excel xp)

    This is what i'm doing... the global variables are the ones in slo.xla

    Global StatColWidth As Integer
    Global StatAlignment As String
    Global sFontName As String
    Global StatPointSize As Integer
    Global DataColWidth As Integer
    Global DataPointSize As Integer

    Sub Start()

    StatColWidth = 4
    StatAlignment = "xlLeft"
    sFontName = "Arial"
    StatPointSize = 8
    DataColWidth = 8
    DataPointSize = 10
    StatAlignment = "xlBottom"

    PastQ = Range("K1").Value
    PresentQ = Range("L1").Value
    csvFileName = Range("csvName").Value

    End Sub

    they are not passing to slo.xla!procedurename. i'm F8'g through it and they are showing nothing.

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

    Re: Call a sub in an .xla from another file (Excel xp)

    I may be wrong, but I don't think that the scope of a Global variable extends to other workbooks. You would have to have a procedure in the xla that you call with the variable values and that procedure would have to set the Global variables. The call would look something like this:

    <pre> Run ("slo.xla!SetGlobals", 4, "xlLeft", "Arial", 8, 8, 10)
    </pre>

    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
  •