Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm a total VB hack - as in cut/copy/paste and try to make things work. The code below worked on my Windows machine, but won't work on my Mac.

I get a file/path access error on this line:

Open MYFILE & "C2NXT_STD.txt" For Output As #FileNum

I'm sure it is due to the Open MYFILE portion referencing the folder path. Maybe I really have a permissions error?

Public Sub a_SaveAsTextWithDelimiter()
Const MYFILE = "Macintosh HD/Users/darrenmason/Documents/Products/Creator NXT/Serials/"
Dim Last_Column As Integer
Dim Last_Row As Long
Dim FileNum As Integer
Dim My_Range As Range
Dim My_Cell As Variant

FileNum = FreeFile

With ActiveSheet.Cells
    Last_Column = .Find("*", [A1], , , xlByColumns, xlPrevious).Column
    Last_Row = .Find("*", [A1], , , xlByRows, xlPrevious).Row
End With

Set My_Range = ActiveSheet.Range("A1:A" & Last_Row)

Open MYFILE & "C2NXT_STD.txt" For Output As #FileNum
For Each My_Cell In My_Range
    If My_Cell.Row Mod 1000 = 0 Then
        Close #FileNum
        Open MYFILE & "C2NXT_STD_" & (My_Cell.Row \ 1000) & "_" & (Format(Date, "yyyymmdd")) & ".txt" For Output As #FileNum
    End If
    Print #FileNum, My_Cell.Value
Close #FileNum
End Sub
share|improve this question

1 Answer 1

Try removing the "Macintosh HD" from your path, so that it starts with the slash.

i.e. Const MYFILE = "/Users/darrenmason/Documents/Products/Creator NXT/Serials/"

share|improve this answer
Thank Randolph, tried that but same error. Have also tried replacing slashes with : to no avail. –  Darren Aug 23 '12 at 16:11
I actually received a brand new script from another forum and am having the exact same error with the folder path. So I'm down to a formatting issue or permissions issue. Anything special I should be doing with the spaces in the folder path? –  Darren Aug 23 '12 at 16:18

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.