# Microsoft Office Application Help - Excel Help forum > For Other Platforms(Mac, Google Docs, Mobile OS etc) >  > [SOLVED] MAC: Using VBA to open an HTML file in default browser

## JimDandy

I have a workbook that we use on both Windows and Mac workstations. One piece of code creates an HTML file then opens that HTML file in the default browser. The section of code that launches the HTML file on Windows is below, but when this is run on a Mac the code sorta runs within a new Excel worksheet. The value *strFName* gets set to *"C:\Users\user\AppData\Local\Temp\GoogleMaps.HTML"* on Windows and *"Machintosh HD:Users:user:Documents:GoogleMaps.html"* on the Mac. I can confirm that manually opening the file works on the Mac, but getting it to launch outside of an Excel worksheet is just not happening. 

Any thoughts about what sort of code would work in this situation? I already use an If/Then/Else function to identify the default file locations, I'm open to doing it for different launching solutions if that gets the job done.




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

----------


## JimDandy

any other thoughts?

----------


## Richard Buttrey

I'm assuming that was a typo of Macintosh (machintosh).

Just a thought but have you tried leaving out the user, i.e.

 "Macintosh HD:Users:Documents:GoogleMaps.html"

----------


## JimDandy

Yes, a typo, thanks. 

I've tried taking _user_ out of the string but that causes an Out of Memory error. It seems that the ActiveWorkbook.FollowHyperlink function only opens a URL, and will not launch the browser with the HTML file.

I'm not familiar enough with the differences between Mac VBA and Windows VBA but maybe there's a way to execute an external program and that that will open a browser with the HTML file, similar to double-clicking the HTML. I've tried a few variations of the Mac VBA Shell function with no success. I'm getting various errors as if the syntax is incorrect. Any ideas what the Shell or other formula syntax might be to launch an HTML file from Excel?

----------


## JimDandy

Does anyone know how to launch Safari from Excel VBA and open the HTML file? If I open the file from Finder it launches the browser and the address is *"file:///Users/username/Documents/GoogleMap.html"*. I've tried variations on the use of Shell but I get either "path not found" or "invalid argument." I cannot seem to get the proper syntax.

----------


## xlnitwit

For 2016 you should use posix paths with / rather than : in them.

----------


## JimDandy

Thank you....On the Windows platform I'm using Office 2016 but on the Mac it's 2011. The issue isn't the formatting of the path as much as it is that Excel on the Mac does not appear to allow launching another program from VBA. My issue is that I build an HTML file from data within the Excel worksheet, and I need to cause the HTML file to be executed outside of Excel. The file is created properly, and executing the HTML file from Finder confirms this but getting Excel Mac to load it is the goal. Excel only seems to be able to open the HTML inside a new Worksheet. If I only needed to open the default browser with a link, that seems to work fine, but I need the entire HTML file to open in the browser, not Excel.

----------


## xlnitwit

I imagine you may need  to use MacScript to run a browser and open the HTML file that way.

----------


## JimDandy

Thank you!

MacScript/AppleScript was the final solution. In Excel I used some MacScript commands to capture the Mac's directory structure and to run an AppleScript routine to actually launch the HTML. Although I didn't test it otherwise, I read that the one caveat that the Mac requires is that the *com.microsoft.Excel* directory be created in the *~/Library/Application Scripts* directory, if not already there, and used to store the AppleScript script files. My guess is that the Mac only allows scripts from Excel to be launched from this single location.

The two separate sections of Excel VBA code used to capture the Mac directory (or Windows) and then to launch the AppleScript script file (or on Windows it will launch the HTML directly):



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


This is the AppleScript file's code (LaunchMaps.scpt), which launches Safari if not already loaded, brings it to the foreground, then loads the HTML file:



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

----------

