+ Reply to Thread
Results 1 to 19 of 19

VB code to run a file on MAC

  1. #1
    Forum Contributor
    Join Date
    09-16-2013
    Location
    Los Angeles, USA
    MS-Off Ver
    Excel 2011
    Posts
    620

    VB code to run a file on MAC

    I am looking for some VB code to run an app script file located in the same directory as the workbook on a mac computer. This is the code I have so far, but it is currently creating a run time 68 error on this line: checker = Dir(correctFile)

    Please Login or Register  to view this content.

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,303

    Re: VB code to run a file on MAC

    Try:
    Please Login or Register  to view this content.
    Remember what the dormouse said
    Feed your head

  3. #3
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: VB code to run a file on MAC

    Hi, Nitefox,

    Your post does not comply with Rule 8 of our Forum RULES. Do not crosspost your question on multiple forums without including links here to the other threads on other forums.

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.

    Expect cross-posted questions without a link to be closed and a message will be posted by the moderator explaining why. We are here to help so help us to help you!

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).

    http://www.mrexcel.com/forum/excel-q...-file-mac.html

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  4. #4
    Forum Contributor
    Join Date
    09-16-2013
    Location
    Los Angeles, USA
    MS-Off Ver
    Excel 2011
    Posts
    620

    Re: VB code to run a file on MAC

    Sorry Holger, here is a link to a similar question I asked a few days ago, from which I was not able to find an answer. I have been looking all over the internet on how to do this on a Mac, but I cant find an answer anywhere:
    http://www.excelforum.com/excel-prog...-computer.html

    Thank you for your response Roy. I tried that code but it didnt seem to do anything. But it didnt come up with an error of any kind either. I tried a different file but still no luck.
    Would it make things easier if i was to put it in the root directory of the computer? I was just hoping I could put it in the same place as the Workbook, but is that confusing things?
    Thanks,
    James

  5. #5
    Forum Expert romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,303

    Re: VB code to run a file on MAC

    First test - does the correctfile variable have the right value?

  6. #6
    Forum Contributor
    Join Date
    09-16-2013
    Location
    Los Angeles, USA
    MS-Off Ver
    Excel 2011
    Posts
    620

    Re: VB code to run a file on MAC

    Im not sure, how would I test that? The file name and extension is correct.

  7. #7
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: VB code to run a file on MAC

    The MacScript command will only run a file that contains an AppleScript.
    Typicaly, those files have a .scpt pseudo-tag. (Mac treats tags like part of the file name)
    Last edited by mikerickson; 10-19-2013 at 06:34 PM.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  8. #8
    Forum Contributor
    Join Date
    09-16-2013
    Location
    Los Angeles, USA
    MS-Off Ver
    Excel 2011
    Posts
    620

    Re: VB code to run a file on MAC

    I tried changing it back to a script file, and ran the following:

    correctFile = ThisWorkbook.Path & Application.PathSeparator & "Camera Log Backup.scpt"

    However it had the same effect. Nothing happened, but there was no error.

  9. #9
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: VB code to run a file on MAC

    See my prevous post.

  10. #10
    Forum Contributor
    Join Date
    09-16-2013
    Location
    Los Angeles, USA
    MS-Off Ver
    Excel 2011
    Posts
    620

    Re: VB code to run a file on MAC

    Sorry im not following you. I tried using an apple script as you recommended in your pervious post but that did not work.

  11. #11
    Forum Expert romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,303

    Re: VB code to run a file on MAC

    What's actually in your script file?

    To test the file name variable you can add a
    Please Login or Register  to view this content.
    line to the code.

  12. #12
    Forum Contributor
    Join Date
    09-16-2013
    Location
    Los Angeles, USA
    MS-Off Ver
    Excel 2011
    Posts
    620

    Re: VB code to run a file on MAC

    When i add that line the message box displays the correct extension for the location of the file, but it doesn't run the file. I tried using different files, but it still isnt running them.

  13. #13
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: VB code to run a file on MAC

    What is in the file?
    How was the file created?
    Unless the file was created with Macintosh's Script Editor program (or the equivalent), the VBA MacScript function won't cause it to run.
    If the file will run on a Windows system, the VBA MacScript function won't cause it to run.

  14. #14
    Forum Contributor
    Join Date
    09-16-2013
    Location
    Los Angeles, USA
    MS-Off Ver
    Excel 2011
    Posts
    620

    Re: VB code to run a file on MAC

    Its an apple script I created with the AppleScript Editor.

  15. #15
    Forum Contributor
    Join Date
    09-16-2013
    Location
    Los Angeles, USA
    MS-Off Ver
    Excel 2011
    Posts
    620

    Re: VB code to run a file on MAC

    The apple script checks for an internet connection, then uses the FTP Application Transmit to backup the Excel workbook to my online server:
    Please Login or Register  to view this content.

  16. #16
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: VB code to run a file on MAC

    I created a simple AppleScript file "test.scpt" and it worked for me
    Please Login or Register  to view this content.

  17. #17
    Forum Contributor
    Join Date
    09-16-2013
    Location
    Los Angeles, USA
    MS-Off Ver
    Excel 2011
    Posts
    620

    Re: VB code to run a file on MAC

    When i first ran that code (with the name of my script file on the third line) it asked for the location of the file, which I gave it. It then came up with a Run Time 5 error on the last line (MacScript myPath). When i run it now, it no longer asks for the location of the file, it just comes straight up with that run time 5 error.

  18. #18
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: VB code to run a file on MAC

    It sounds like the AppleScript is interfearing with the Excel somewhere.

    Have you tried running that script (not from Excel) with the application "Transmit" not open?

  19. #19
    Forum Contributor
    Join Date
    09-16-2013
    Location
    Los Angeles, USA
    MS-Off Ver
    Excel 2011
    Posts
    620

    Re: VB code to run a file on MAC

    When i run the apple script in the finder it works fine.

+ 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. [SOLVED] Code to open another excel file, file name depending on cell contents
    By L-Drr in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-02-2013, 11:09 AM
  2. Replies: 3
    Last Post: 05-21-2013, 08:22 AM
  3. Excel 2010 file with VBA save and send code works-but file can't be found.
    By carlton.clay in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-13-2013, 09:46 AM
  4. [SOLVED] VBA Code to Enter File Name, Activate the File, and Run Macro on File
    By DHartwig35805 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-09-2012, 03:49 PM
  5. [SOLVED] Import VBA Code in Excel-File ? (Export VBA Code to file)
    By Matthias Pospiech in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-22-2005, 01:06 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