Error 1004: Application.Dialogs(xlDialogOpen).Show Mac Excel 2016 Importing Data

  • Hello
    I am trying to use the below code on my Mac running Excel 2016 V15.33.


    Code is to import data from a text file into a new worksheet.
    The code always fails on line "RetVal = Application.Dialogs(xlDialogOpen).Show("*.txt",,True)"
    with error :
    Run-time error '1004':
    '' could not be found.Check the spelling of the file name, and verify that the file location is correct.
    If you are trying to open the file from your list of most recently used files on the File menu, make sure that the file has not been renamed, moved, or deleted.




    I appreciate any help solving the issue.
    Cheers
    Jan

  • Re: Error 1004: Application.Dialogs(xlDialogOpen).Show Mac Excel 2016 Importing Data


    Will this work? (I don't have a Mac, just changed syntax to what would work on PC)

    Best Regards,
    Luke M
    =======
    "A little knowledge is a dangerous thing."

  • Re: Error 1004: Application.Dialogs(xlDialogOpen).Show Mac Excel 2016 Importing Data


    Hi Luke,
    Thank you for your extremely prompt response...I posted the code into my test file but errored on line: Call Application.FileDialog(msoFileDialogOpen).Filters.Clear
    Error: Run-time error '438':
    Object doesn't support this property or method.


    Perhaps something to do with Excel for Mac?
    I also tried this simple code from
    https://answers.microsoft.com/…4f-a1a0-41e0959f28b8?db=5 but could not get it to work either. I am new to VBA but have had other vba macros work.


    Cheers Jan

  • Re: Error 1004: Application.Dialogs(xlDialogOpen).Show Mac Excel 2016 Importing Data


    Hello Again,
    After spending many hours searching the web, I have found a couple of articles that may be of interest to other MAC users. These are quite complex (at least to me as a newbie).
    Apparently, the Mac does NOT support [FONT=&amp]Application.filedialog - [/FONT]https://answers.microsoft.com/…d2-4379-842a-d6b9efe9f66f
    This article also refers to:
    Problems with Apple’s sandbox requirements and Mac Office 2016 with VBA code - http://www.rondebruin.nl/mac/mac034.htm
    Select files on a Mac (GetOpenFilename) - http://www.rondebruin.nl/mac/mac015.htm


    I also came across this code which actually does work exactly as required on the MAC.



    Can the original code I posted be modified based on the above? I have tried but still get errors as I am still trying to understand/learn the logic.
    Many thanks.
    Jan

  • Re: Error 1004: Application.Dialogs(xlDialogOpen).Show Mac Excel 2016 Importing Data


    Thanks for link to Ron's site. Using his page, it looks like this should work. I've tried to clearly comment where I've pieces your bit of code in.

    Best Regards,
    Luke M
    =======
    "A little knowledge is a dangerous thing."

  • Re: Error 1004: Application.Dialogs(xlDialogOpen).Show Mac Excel 2016 Importing Data


    Hi Luke,


    Many thanks for your time reviewing and sorting the above which does work. I hope Microsoft come up with a simpler solution in the future to achieve this with the Mac so that files can be compatible with both Mac and PC.
    The reason I wanted to add to the existing code was because the file was written by someone else and I didn't want to completely rewrite to work on the Mac.
    All the best
    Cheers Jan

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!