# Microsoft Office Application Help - Excel Help forum > For Other Platforms(Mac, Google Docs, Mobile OS etc) >  >  Macro to open file on computer

## Nitefox

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.

----------


## hamjam

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 ?



```
Please Login or Register  to view this content.
```


Regards

----------


## Nitefox

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.

----------


## hamjam

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



```
Please Login or Register  to view this content.
```


Regards

----------


## Nitefox

Sorry im a little confused. Is this what the code should be:




```
Please Login or Register  to view this content.
```


Because that gave me the error 'Invalid Outside Procedure'

----------


## hamjam

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

----------


## Nitefox

So this is the code I entered:



```
Please Login or Register  to view this content.
```


It gives me 'Run Time Error 53 - file not found'
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)

----------


## hamjam

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:



```
Please Login or Register  to view this content.
```


So try to add the full path, it does not seems to work on relative path references.

Regards

----------


## Nitefox

I tried this, which is the Mac equivilant of C:\



```
Please Login or Register  to view this content.
```


Im still getting error 53.
I have the file in my root directory.

----------


## hamjam

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

----------


## Nitefox

I changed it to:

temp = MacScript("/Camera Log Backup.app")

But I get a run time 5 error.

----------


## hamjam

Hello
Its a pretty meaningless error, perhaps it is struggling with finding the file.
Replace your MacScript line with something like this



```
Please Login or Register  to view this content.
```


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.
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

----------


## Nitefox

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

----------


## Richard Buttrey

Are you allowing for the Mac's different path separator? 

i.e.  : rather than \

----------


## Nitefox

I am, I changed it to :

----------


## hamjam

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

----------


## Nitefox

Will do, thanks for you help.

----------

