The Situation: I am working on a project that retrieves operating values from a control system server. This requires both access to the server and an accompanying proprietary excel add-in. I want to me able to work on other aspects of the project that do not require this interaction when I am at other computers (ie: at home where I don't have either server access or the add-in). So I created dummy functions that accept the same parameters as those in the add-in and return dummy results. I used compilation constants to tell VBA whether or not to compile them. In other words, when I am at a station with the required access, I can switch the compilation constant value and the dummy functions will no longer be compiled. However, no matter what value I assigned the constant, it was always evaluated as FALSE. After much frustration with this, I finally figured out that this was because the compilation constant was defined in a separate module from the modules which compiled the functions. So now I have the same constant declared in each module, which is annoying because now I have to change all of them.
Example Code
[highlight]The Question:[/highlight] Is it possible to make compilation constants global?
-JTBorton
Well, You can try banging your head against the wall, but you just end up with lost-time injuries and damaged equipment. [M. Passman]
Example Code
Code:
#[COLOR=darkblue]If[/color] AddinPresent [COLOR=darkblue]Then[/color]
[COLOR=darkgreen]'If the add-in is present, compile the following functions[/color]
Public Function GetTagQuality(TagName As String, Block_Parameter As String) As String
'Returns the current status of a tag: Not Found, Bad Reading, or Good
Dim vntValue As Variant
vntValue = GetPointVal(strcHoneyWellServer, TagName, Block_Parameter)
GetTagQuality = Switch(InStr(vntValue, "#ERROR"), "NOT FOUND", InStr(LCase(vntValue), "bad"), "BAD READING", True, "Good")
End Function
#[COLOR=darkblue]Else[/color]
[COLOR=darkgreen]'If the add-in is NOT present, compile the following functions[/color]
Public Function GetTagQuality(TagName As String, Block_Parameter As String, Optional Test As Boolean = True) As String
[COLOR=darkgreen]'A variation of the GetTagQuality function that can be used to work on the project when at a station _
where the add-in and the server are not available.[/color]
GetTagQuality = "Good"
End Function
#[COLOR=darkblue]End If[/color]
[highlight]The Question:[/highlight] Is it possible to make compilation constants global?
-JTBorton
Well, You can try banging your head against the wall, but you just end up with lost-time injuries and damaged equipment. [M. Passman]