title: VBA - username in both Windows and OSX
body: <p>I'm writing VBA code to gather input from several xlsx files and combine them into a single master sheet. Since the users of this sheet are mixed Windows and OSX users, my code needs to be universal across both platforms.</p>
  
  <p>One of the things I'd like to achieve is to determine the user's username. This can be done using <code>environ("username")</code> on Windows and <code>MacScript</code> on OSX. However, below code cannot be compiled on Mac, since it doesn't know <code>environ()</code>.</p>
  
  <blockquote>
  <pre><code>OS_IS_MAC = Application.OperatingSystem Like "*Mac*"
  If OS_IS_MAC Then
     sMyScript = "set userName to short user name of (system info)" &amp; vbNewLine &amp; "return userName"
     USERNAME = MacScript(sMyScript)
  </code></pre>
    
    <p>Else</p>
  
  <pre><code>   USERNAME = Environ("UserName")
  </code></pre>
    
    <p>End If</p>
  </blockquote>
  
  <p>How can I get around this?</p>