runtime error 1004 saveAs mac Text file

J

Janis

I get a runtime error on the ActiveWorkbook.saveas line.
I want to save the file as a Mac text file (19)
I would like it to have the .txt extension.
I would like to have the date and time appended so that it doesn't write
over another file previously saved.
thanks,

I get a runtime error on the activeworkbook.saveas line.

Sub saveIndesign()
'Appends date to filename so as to not write over an existing file

' saveIndesign Macro

Const fPath As String = "Mac OS X:Users:jrough:Documents:"
Dim fName As String
Dim myFileName As String
myFileName = Left(ActiveWorkbook.Name, Len(ActiveWorkbook.Name) - 4) & Date
& ".txt"

fName = fPath & myFileName & time()
ActiveWorkbook.SaveAs Filename:=fName, FileFormat:=19
MsgBox "File Saved to " & fName
End Sub


I checked that the diretory is read/write, the filename & path is under 200
characters, the name isn't already created. That is why I would like the
time appended to the filename and the date.

Thanks,
 
B

Bob Greenblatt

I get a runtime error on the ActiveWorkbook.saveas line.
I want to save the file as a Mac text file (19)
I would like it to have the .txt extension.
I would like to have the date and time appended so that it doesn't write
over another file previously saved.
thanks,

I get a runtime error on the activeworkbook.saveas line.

Sub saveIndesign()
'Appends date to filename so as to not write over an existing file

' saveIndesign Macro

Const fPath As String = "Mac OS X:Users:jrough:Documents:"
Dim fName As String
Dim myFileName As String
myFileName = Left(ActiveWorkbook.Name, Len(ActiveWorkbook.Name) - 4) & Date
& ".txt"

fName = fPath & myFileName & time()
ActiveWorkbook.SaveAs Filename:=fName, FileFormat:=19
MsgBox "File Saved to " & fName
End Sub


I checked that the diretory is read/write, the filename & path is under 200
characters, the name isn't already created. That is why I would like the
time appended to the filename and the date.

Thanks,
Janis,

The problem is that the time function returns the time as a string
containing colons. These are illegal in a Macintosh file name as the colon
indicates a directory node. Try this to strip the colons:
fName = fPath & myFileName & format(time(),"hhmmss")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top