+ Reply to Thread
Results 1 to 7 of 7

Excel VBA code can't find file path on MAC

  1. #1
    Registered User
    Join Date
    07-21-2022
    Location
    Lincoln, CA
    MS-Off Ver
    Excel for Mac version 16.63.1 365 Subscription
    Posts
    4

    Excel VBA code can't find file path on MAC

    I have the following setup:

    MacBook Pro M1 with macOS Monterey version 12.3
    Parallels Desktop 17 for Mac. Version 17.1.4
    Excel for Mac version 16.63.1. MS Office 365 subscription.
    Windows 10


    My code worked on my old Mac 2011 with parallels however it's having trouble opening a file.

    I get the following error: Run-time error '-2147221014(800401ea)':
    when I use either one of the paths below.

    version 1
    PDFTemplateFile = ActiveWorkbook.Path & "/SCUF For Emailing.pdf"

    or
    PDFTemplateFile = "W:/SCUF For Emailing.pdf"

    The. PDF form is in the same folder as the active workbook and on Drive W: This drive is a separate hard drive connected to the mac. The drive letter designation is from File Explorer in Windows.

    The code fails at this line which follows shortly thereafter; Thisworkbook.FollowHyperlink PDFTemplatefile.

    Also, Use Rosetta is unchecked for my Excel Application.

    Any help would be appreciated.
    Jeff

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,995

    Re: Excel VBA code can't find file path on MAC

    I do not have a Mac but my understanding is that the path delimiter on a Mac is : not \ or / as in Windows. Try making that change, if you will use this exclusively on a Mac. I don't know how it ever worked in the past.

    If you need to use it on both Windows and Mac then use Application.PathSeparator wherever you need to use a delimiter.
    Jeff
    | | |·| |·| |·| |·| | |:| | |·| |·|
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    07-21-2022
    Location
    Lincoln, CA
    MS-Off Ver
    Excel for Mac version 16.63.1 365 Subscription
    Posts
    4

    Re: Excel VBA code can't find file path on MAC

    That didn't work and application.pathseparator value is "/", which is what I had.
    Sorry.

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,995

    Re: Excel VBA code can't find file path on MAC

    I just noticed you listed Windows 10. Are you running a virtual Windows 10 OS on a Mac?

  5. #5
    Forum Expert CheeseSandwich's Avatar
    Join Date
    12-22-2021
    Location
    Kent, England
    MS-Off Ver
    365 - 2503
    Posts
    1,453

    Re: Excel VBA code can't find file path on MAC

    Would also be interesting to know what is returned when you run the below:

    Please Login or Register  to view this content.
    If things don't change they stay the same

  6. #6
    Registered User
    Join Date
    07-21-2022
    Location
    Lincoln, CA
    MS-Off Ver
    Excel for Mac version 16.63.1 365 Subscription
    Posts
    4

    Re: Excel VBA code can't find file path on MAC

    I though I had replied previously, but I will try again.

    I tried simplifying things and created a new module in the same workbook with the code as follows:
    Sub OpenPDF()
    ThisWorkbook.FollowHyperlink ActiveWorkbook.Path & "SCUF.pdf"
    'Note: I renamed the file so that there weren't any spaces'
    End Sub

    The ActiveWorkbook Path is /Users/jeffhanner/desktop/create SCUF/

    I can substitute the path and file name for a URL and it opens the URL in the browser, however I tried to open many different files and got the same error - that it can't find the file. Since I'm only working with Excel for Mac and not Access right now, Windows 10 is suspended in Parallels. One thing that is interesting is that it can find and open the file when MS Access is used and it can populate the fields in the PDF, but it can't save the document as in the past. I'm not concerned right now about making it work from Access, so that is why I'm trying it with just Excel for Mac. I don't know what else to do. Thanks for you help so far.

    I did find out that the Hyperlink function from within a cell works fine and opens the pdf file.
    Last edited by Jeffhanner; 07-22-2022 at 09:12 PM. Reason: Additional Finding

  7. #7
    Registered User
    Join Date
    07-21-2022
    Location
    Lincoln, CA
    MS-Off Ver
    Excel for Mac version 16.63.1 365 Subscription
    Posts
    4

    Re: Excel VBA code can't find file path on MAC

    I've discovered several important things to clarify my problem.

    1. Originally this was a problem with MS Access calling Excel Macros which were to open a PDF form and then populate it with Excel Data which it didn't

    2. I removed MS Access from the problem and worked with Excel Macros alone. I eventually got Thisworkbook.Hyperlink to find the file (on the MAC). However, when the PDF file opened, none of the keystrokes sent with Application.Sendkeys worked.

    3. I watched a video from Excel Freelancers and the code I had was correct.

    4. I had access to a PC so I moved the Excel file with its VBA code and the PDF file to C:\SCUF. Not only did the PDF file open, the file was filled and saved correctly.

    So that leads me to believe that either the code doesn't work correctly with the MacBook Pro M1 or a setting has to be changed. It would be great if the MS Access code could call the Excel Macros on the Mac, but I've finished what I needed to do on the PC.

    If you come up with anything, please let me know. Thanks for your help.
    Last edited by Jeffhanner; 07-24-2022 at 07:42 PM. Reason: Corrections

+ 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. How do I prompt user to find path in excel and paste that path into my current VBA
    By chrispikekerry in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 07-20-2022, 02:30 PM
  2. VBA help - Code to update excel links when file path changes
    By jirose93 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-17-2019, 10:45 PM
  3. [SOLVED] Find and split file path from Excel Cell
    By Honest Peddler in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-09-2018, 08:38 AM
  4. Mac Excel cannot find file path - code error
    By MermaidNiki in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 3
    Last Post: 07-03-2018, 03:49 PM
  5. consolidating excel files into one file not using hard code of folder path
    By rrakkki in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-21-2011, 09:05 AM
  6. Can you use a piece of VB code to get the path of the current excel file?
    By Smurlos in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 01-03-2011, 08:18 AM
  7. Replies: 7
    Last Post: 10-09-2009, 10:10 AM

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