What code would I use to open a file called Camera Log Backup.app located in the same directory as the Workbook?
I am using Excel 2011 on a mac.
What code would I use to open a file called Camera Log Backup.app located in the same directory as the Workbook?
I am using Excel 2011 on a mac.
Hello
There are 2 things to do.
1. enter your code in the Open Workbook event of the workbook (go to macro editor and select "thisWorkbook" on the tree view and change the event dropdown to see "Open"). This should place the header of Private Sub Workbook_Open() in the space
2. not sure of the type of your file, and what you plan to do with its contents ?
RegardsPlease Login or Register to view this content.
Most helpful to mark solved items as such (see help for directions). Star ratings are always welcome.
Its basically just an apple script that I want to run from a macro in Excel. The script just runs in the background and does its thing then exits. I just need the excel macro to trigger it form the Spreadsheet.
Hello
My code opens the file, not runs it.
So you need to use the SHELL() function like :
Replace my code (in same place) with
RegardsPlease Login or Register to view this content.
Sorry im a little confused. Is this what the code should be:
Because that gave me the error 'Invalid Outside Procedure'Please Login or Register to view this content.
Sorry I should have been clearer.
The OPEN will open the file to examine its contents.
The SHELL will run the file without opening it.
So remove lines 2 and 3 and keep 1
So this is the code I entered:
It gives me 'Run Time Error 53 - file not found'Please Login or Register to view this content.
I have the file in the same location as the workbook. I tried putting it in the root directory of my HD incase it was looking there instead but it still didnt work. (i would like to keep the file in the same directory as the workbook if possible)
Hello
It may need an absolute path reference, so I tested with creating an .exe (Windows) and putting it on my folder : D:\Documents\Excel\test.exe
It ran this file with the code:
So try to add the full path, it does not seems to work on relative path references.Please Login or Register to view this content.
Regards
I tried this, which is the Mac equivilant of C:\
Im still getting error 53.Please Login or Register to view this content.
I have the file in my root directory.
Hello
I researched this a bit and it does not always seem that Shell() works properly on the Mac. Some people suggest Macscript() which is pretty similar but runs Mac scripts - which may be in line with your intentions.
So replace the Shell() with Macscript(), just comfirm in your help that the parameters are the same, I think so.
Regards
I changed it to:
temp = MacScript("/Camera Log Backup.app")
But I get a run time 5 error.
Hello
Its a pretty meaningless error, perhaps it is struggling with finding the file.
Replace your MacScript line with something like this
So the logic is to attempt with your file path and name. It attempts to confirm if it can find it with the Dir function.Please Login or Register to view this content.
If not good, it should open a dialog to manually find your file and then replace the file name and path with the manually extracted details and then run the script.
I can't really test if that will work on your Mac though so you will have to provide feedback
Regards
This time I got a 1004 run time error, with the following line highlighted:
correctFile = Application.GetOpenFilename("Text Files (*.app), *.app") 'not found, open dialog for manually search
Are you allowing for the Mac's different path separator?
i.e. : rather than \
Richard Buttrey
RIP - d. 06/10/2022
If any of the responses have helped then please consider rating them by clicking the small star icon below the post.
I am, I changed it to :
Hello
My suggestion is to re-post the question, I can't test the code (don't have a Mac) so I can't provide guaranteed working code. You could also try to search for the specific error message in a search engine and see if there are suggestions to overcome those.
Best of luck
Will do, thanks for you help.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks