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
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
You have to specify Mac-style path. In particular, they use ":" instead of backslash.
Don't have my mac handy to test...
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,965
Messages
6,122,499
Members
449,089
Latest member
Raviguru

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top