title: How to save a file to the Desktop in VBA (Mac)
body: <p>I am writing a Macro in VBA that needs to be compatible for both Windows and Mac machines. I have everything working up until the end when I need to save the file to the users Desktop as a Tab Delimited Text File. Below is the code I have tried, but I keep getting an error. Any help is appreciated. Thanks!</p>
  
  <pre><code>'Export doc as Delimited Text
  
  Dim OS As String
  OS = Application.OperatingSystem
  
  Dim un As Variant
  
  un = (Environ$("Username"))
  
  Dim wb As Workbook
  Set wb = Workbooks.Add
  ThisWorkbook.Sheets("dataExport").Copy Before:=wb.Sheets(1)
  
  If InStr(OS, "Windows") &gt; 0 Then
  
  wb.SaveAs Filename:="C:\Users\" &amp; un &amp; "\Desktop\" &amp; CaseNum &amp; ".txt", FileFormat:=xlText
  
  Else
  
  wb.SaveAs Filename:="/Users/" &amp; un &amp; "/Desktop/" &amp; CaseNum &amp; ".txt", FileFormat:=xlText
  
  End If
  </code></pre>