vba - Setting a constant from a variable value -
i set path of database constant.
the problem path stored in ini file , variable set when outlook launched. vba won't compile if constant isn't hardcoded.
the reason why want utilize constant because, reasons, after few hours/days outlook running, seems lose value of variables (never experienced problem hardcoded constant). path variable emptied, , when vba tries reach database, user gets error.
i can't hardcode path because users don't utilize same server unc path. path might alter 1 time year or so, it's easier edit ini file , restart outlook inquire programmer edit right line in code on each user's computer.
any ideas?
you cannot alter value of constant @ run-time. values set when code compiled (even if don't explicitly compile vba code still done just-in time (jit) in background).
if don't want running lookup code (because inefficient, example), can utilize static variable within function:
class="lang-vb prettyprint-override">function getdbpath() string static dbpath string if len(dbpath) = 0 dbpath = 'your code here' end if getdbpath = dbpath end function
vba outlook
No comments:
Post a Comment