VBA Excel - Macscript causing problems on windows when using IIF -


i'm creating macro opens file has on computer , in order must know person's username / work id. person's work id i've tried using following:
sso = iif(instr(application.operatingsystem, "windows") = 1, environ("username"), _ 'macscript("(user name string)"))
running on windows returns error because of macscript (i think) , i'd assume same happen vice versa, though error part of iif never accessed i'm guessing seeing whole line executed why there problem, on error resume next not here.

i know can overcome using if , else statement want know if i'm right / why problem occurs , if there other more sophisticated ways of achieving want.

thanks

the iif function evaluates both true , false parts, or rather attempts so. there no short-circuit. assumption why it's failing (and can't use oern) correct. may take @ conditional compilation logic, if parts of code not compile on windows (or mac, respectively).

http://msdn.microsoft.com/en-us/library/aa240847(v=vs.60).aspx


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -