VBA from Windows to Mac

KurtyK

New Member
Joined
Jul 8, 2014
Messages
8
Hi all,

I had this code working great on my PC. When converting to mac, it will create the text file but fails at the "save-as". I have the newest excel for mac.

Can any give advice?


Here is the
Rich (BB code):
Sub ExportCSV()
'
' ExportCSV Macro
Dim MyPath As String
Dim MyFileName As String
'The path and file names:


    MyPath = ActiveWorkbook.Path & "\"
    MyFileName = Worksheets("CustInfo Sheet").Range("B4").Value
If Not Right(MyPath, 1) = "\" Then MyPath = MyPath & "\"


'Makes sure the filename ends with ".txt"
If Not Right(MyFileName, 4) = ".txt" Then MyFileName = MyFileName & ".txt"
'Copies the sheet to a new workbook:
Sheets("CustInfo").Copy
'The new workbook becomes Activeworkbook:
With ActiveWorkbook
'Saves the new workbook to given folder / filename:
    .SaveAs Filename:= _
        MyPath & MyFileName, _
        FileFormat:=xlTextPrinter, _
        CreateBackup:=False
'Closes the file
    .Close False
End With
 

Some videos you may like

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.

Tetra201

MrExcel MVP
Joined
Oct 14, 2016
Messages
3,542
You have to specify Mac-style path. In particular, they use ":" instead of backslash.
Don't have my mac handy to test...
 
Last edited:

Watch MrExcel Video

Forum statistics

Threads
1,099,063
Messages
5,466,370
Members
406,478
Latest member
Amar kumar

This Week's Hot Topics

Top