macID for CSV in mac excel 2011????

straub

New Member
Joined
Aug 15, 2011
Messages
4
Hello Team,

Can anyone tell me what the macID is for opening up CSV files.

FileName = Dir(Path, MacID("XLS8")) ' This will open excel files but need the macId for CSV...

Thanks,


Straub
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
try
MacID("public.csv")

I dont use DIR much, I ususaly use VBA MacScript command to access Applescript for file management. What is the goal? Might it be easier to use Applescripts Choose File or Choose Folder commands? (The filtering is a bit easier to find documentation)
 
Upvote 0
To achieve your task, you might use this

Code:
Dim PathToFile As String

PathToFile = "False"

On Error Resume Next
PathToFile = MacScript("choose file of type {""TEXT""}")
On Error GoTo 0

If PathToFile = "False" Then
    MsgBox "Canceled"
    Exit Sub
Else
    Workbooks.Open PathToFile
End If

According to this site
http://developer.apple.com/library/...eScriptLangGuide/introduction/ASLR_intro.html
the of type argument is a Uniform Type Identifier, which may (or may not) be the same as VBA's MacID.

To get the of type argument for a particular file, you can use this code.

Code:
Sub Get_OfType_Argument()
    Dim InfoFrom As String
    InfoFrom = "False"
    
    On Error Resume Next
    InfoFrom = MacScript("info for (choose file)")
    InfoFrom = Split(InfoFrom, ", file type:")(1)
    InfoFrom = Trim(Split(InfoFrom, ",")(0))
    MsgBox InfoFrom
End Sub
 
Upvote 0
Hi mikerickson, thanks! Your method works but it only allowed me to open one file at a time. Found it in Access... strange but worked.

Thanks a million!

link:
http://office.microsoft.com/en-us/access-help/dir-function-HA001228824.aspx

To iterate over all files in a folder, specify an empty string:

<code>Dir("")</code></pre>
sample code
Sub openAllfilesInFolder()
Dim MyPath As String
Dim MyFile As String
Dim wkb As Workbook


MyPath = "Macintosh HD:Users:blahblah:"

If Right(MyPath, 1) <> ":" Then MyPath = MyPath & ":"

'Don't care what files it opens, then use this method (This directory had nothing but my csv files)
MyFile = Dir("")

'If you want to open specific files then use this method (i.e. opens text files)
MyFile = Dir(MyPath, MacID("TEXT"))


Do While Len(MyFile) > 0
Set wkb = Workbooks.Open(FileName:=MyPath & MyFile)
'Your code here

wkb.Close savechanges:=False
MyFile = Dir
Loop

End Sub
 
Upvote 0

Forum statistics

Threads
1,224,564
Messages
6,179,544
Members
452,925
Latest member
duyvmex

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