+ Reply to Thread
Results 1 to 3 of 3

getting filename using Dir function on Mac

  1. #1
    Forum Contributor aprildu's Avatar
    Join Date
    04-13-2014
    Location
    Barrie,On, Canada
    MS-Off Ver
    Excel 2016
    Posts
    175

    getting filename using Dir function on Mac

    I get a runtime error 53 "file not found" by using dir to get filename. as below:

    Please Login or Register  to view this content.
    The debug stops at fileName = Dir(folderPath & "\"). Many thanks in advance!

  2. #2
    Registered User
    Join Date
    08-08-2014
    Location
    Lancaster, PA
    MS-Off Ver
    2016 (windows & mac)
    Posts
    94

    Re: getting filename using Dir function on Mac

    OS X uses a different path separator than windows. you want to use "/" rather than "\". it's also possible to use ":"

    if you need this code to work on both windows & OS X then you can use Application.PathSeparator to return the correct path separator for the current system.

    ron de bruin's site has some excellent info on writing mac-specific VBA and has a whole section on working with files & folders

  3. #3
    Forum Contributor aprildu's Avatar
    Join Date
    04-13-2014
    Location
    Barrie,On, Canada
    MS-Off Ver
    Excel 2016
    Posts
    175

    Re: getting filename using Dir function on Mac

    Thanks thatandyward. I did find the code from his website however it's giving me the error.

    At the bottom of that page, it says: "it return a path like this :
    Macintosh HD:Users:RDB:Desktop:YourFolder:
    And in 2016 a path like this :
    /Users/RDB/Desktop/YourFolder/".

    Does it mean I should not add the "/" in dir(folderpath) at all because it's already in the returned path?
    Something like:
    Please Login or Register  to view this content.
    Last edited by aprildu; 05-27-2017 at 11:16 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. FileName / Path Function Modification
    By Richard_Thornton in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-21-2014, 03:52 AM
  2. Using a wildcard in path (not filename) with Dir function
    By MaartenKoller in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-10-2013, 06:19 AM
  3. [SOLVED] How To Use VBA Windows Active function with a wildcard filename
    By zalora in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-13-2013, 05:47 AM
  4. HYPERLINK function without filename
    By urungus in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-22-2008, 08:29 AM
  5. Referencing filename in a saveas function
    By Mechroneal in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-03-2007, 09:53 AM
  6. [SOLVED] how get filename with worksheet function?
    By Ian Elliott in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 06-26-2006, 03:35 PM
  7. Function: Filename
    By MarkC in forum Excel General
    Replies: 4
    Last Post: 04-23-2005, 06:08 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1