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!
'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") > 0 Then
wb.SaveAs Filename:="C:\Users\" & un & "\Desktop\" & CaseNum & ".txt", FileFormat:=xlText
Else
wb.SaveAs Filename:="/Users/" & un & "/Desktop/" & CaseNum & ".txt", FileFormat:=xlText
End If