anupagarwal06
New Member
I have a VBA code on an Excel file which works absolutely fine on Office 2013 on Windows. However it does not work on MS Office on MAC. The Code extracts the list of excel files in in the folder in which the VBA file is kept. The code is as below.
[pre]
[/pre]
In MAC it gives Error 68, (Device unavailable) at MyFile = Dir(MyFolder & Application.PathSeparator & "*.xls")
When I change the definition to MyFile = Dir(MyFolder & Application.PathSeparator) the code runs, but the file name list generated does not show the right excel files, but some random file names for which part of name matches. I think these are some automatic system generated temporary files.
I think the problem is because of the file system of MAC. Can someone please help?
[pre]
Code:
Sub List_Files()
Dim MyFile As String
Dim a As Integer
MyFolder = ThisWorkbook.Path
MyFile = Dir(MyFolder & Application.PathSeparator & "*.xls")
a = 1
Do While MyFile <> ""
a = a + 1
Cells(a, 1).Value = MyFile
MyFile = Dir
Loop
End Sub
In MAC it gives Error 68, (Device unavailable) at MyFile = Dir(MyFolder & Application.PathSeparator & "*.xls")
When I change the definition to MyFile = Dir(MyFolder & Application.PathSeparator) the code runs, but the file name list generated does not show the right excel files, but some random file names for which part of name matches. I think these are some automatic system generated temporary files.
I think the problem is because of the file system of MAC. Can someone please help?