Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Call Public constants from other project
Hi,
Is it possible to refer to / call a Public constant in another project? If so, how? The idea: I have some constants that change often and are used in alsmost all of my projects. I want to store them in one place, and modify them (if needed) in one place, so they can kick in in the other projects that refer them. Thanks! M -- Message posted via http://www.officekb.com |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Call Public constants from other project
Most efficent way is to set a reference to the project containing the
constants and call them directly. However that's not always practical, another way ' in Constants.xls Public Const cNUM As Long = 123 Public Const cTXT As String = "abc" Public Function getConstant(sName As String) As Variant Select Case sName Case "cNUM": getConstant = cNUM Case "cTXT": getConstant = cTXT Case Else: getConstant = -99 End Select End Function 'in another project Sub test() Dim c c = Application.Run("Constants.xls!getConstant", "cNUM") MsgBox c End Sub But why not put your constants in cells, eg c = Workbooks("Constants.xls").Worksheets("Sheet1").Ra nge("A1") Regards, Peter T "Michiel via OfficeKB.com" <u40062@uwe wrote in message news:9e487bfeaba18@uwe... Hi, Is it possible to refer to / call a Public constant in another project? If so, how? The idea: I have some constants that change often and are used in alsmost all of my projects. I want to store them in one place, and modify them (if needed) in one place, so they can kick in in the other projects that refer them. Thanks! M -- Message posted via http://www.officekb.com |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Call Public constants from other project
Hi Peter T.
Thank you this is a great solution, thak you for sharing! And yes putting them in a workbook could be a solution but I actually intend to put them in the code attached to Personal.xls. Then it will be always available and not "pollutingly visible". M. Peter T wrote: Most efficent way is to set a reference to the project containing the constants and call them directly. However that's not always practical, another way ...................... But why not put your constants in cells, eg -- Message posted via http://www.officekb.com |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Public variable (or Public Const?) | Excel Programming | |||
How to call functions of a DLL in Excel and in a .net project | Excel Programming | |||
call a excel function from a vb project | Excel Programming | |||
Referencing Call to Another Project | Excel Programming | |||
project wide compconditional compile constants | Excel Programming |