• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Macro for Office 2011 for Mac

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]
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
[/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?
 
Hi,


is the path separator for Windows, not Mac ‼


So you just have to delete it in your line …


Even like this can't work in Windows …
 
Good day anupagarwal06


There are many differences between Windows and Mac VBA Excel, it is not just a case of porting the code over, I think you would find this link of use.


http://www.rondebruin.nl/mac.htm
 
Back
Top