Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Open file in VBA on Mac

Beginner!
Having a problem creating a file on Mac using VBA.
I copied the folders pathname but it does not work. Error says – "bad file name or number". I suspect that the problem lies within the pathname, if so what is the right way?

Public Sub task()
Open "/Users/user/test.csv" For Output As file
Close file
End Sub

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

See this for the docs on Open:
https://docs.microsoft.com/en-us/office/vba/Language/Reference/User-Interface-Help/open-statement

In your case:

Public Sub task()
Open "/Users/user/test.csv" For Output As #1
' do whatever output you need here, then ...
Close #1
End Sub

Because of Apple’s sandboxing, there might be other issues with the file path, but try the above for starters.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading