Friday, October 21, 2016

Installing Microsoft Office 2010 on WINE for OSX

Installing Microsoft Office 2010 on WINE for OSX


I should be able to graduate with my AAS in Computer Information Systems at the end of this summer.  At this point I am down to the last couple credits that I need, some of which just being any CIS electives, so I picked up an Adobe CS5 and an Excel 2010 (the Windows version) class to knock out some easy credits.  Now, it may come as no surprise to anyone that I prefer to work in an OSX environment wherever possible.  I have OSX and all of its wonderful software to do the vast majority of my computing needs, for all of my *NIX type stuff there is MacPorts and for everything else there is WINE.  And if all else fails, there is VirtualBox, and in the rare case that I absolutely need to be actually booted into Windows or Linux, I can multiboot.  That being said, I try to remain booted into OSX whenever I can, and even though VirtualBox or Parallels do provide me with options, running Windows in a virtual machine is slow and cumbersome even on my relatively powerful desktop, and I try to avoid it at all costs on my Thinkpad T60 hackintosh.


But getting back to the subject, I am taking an Excel 2010 class this summer and therefor needed to install Excel on OSX.  Sure, I already have Office 2011 for Mac but it is not the same and probably wont suffice for a class that is specifically about Office 2010 on Windows.  In the past, I have installed Office 2007 on WINE without any problems.  It works flawlessly and installs without any workarounds, winetricks or winecfg tweaks whatsoever.  Microsoft Office 2010?  Yeah... Not so much.  After a couple of days of messing with it, I finally managed to get Office 2010 installed on Wine, both on Snow Leopard and on Mountain Lion, and here is how I managed it.

There are quite a few prerequisites.  First off, WINE is an open source application that comes from the Linux/BSD world, and it needs an X environment to work in.   On Snow Leopard there is a built in X server, the /Applications/Utilities/X11.app which works flawlessly.  With the release of Mountain Lion, users are left to fend for themselves, so the first thing you will have to do is install XQuartz, a community developed X server that is compatible with Mountain Lion.  You can get that here http://xquartz.macosforge.org/landing/

The current release version of XQuartz is 2.7.4.  After you download the .dmg and install XQuartz, you can proceed with the next step.

Next, you are going to need MacPorts, which is a repository of hundreds of free/open-source applications, many of which you will be familiar with if you use Linux.  But, MacPorts has some prerequisites as well.  In order to install MacPorts, you must first install and configure Xcode.

Xcode is a free app available on the App Store.  You must be running Mac OSX 10.7.4 or higher to install it, and since we are targeting Mountain Lion with this guide thats not a problem.  Now, once you have downloaded and installed Xcode, you will also need to install an Xcode package called "command line tools", which contains the OSX binaries you need to be able to compile and build MacPorts software.  As of the release of Xcode 4.3, command line tools is no longer bundled with Xcode, so you will need to download it manually.  To do so, you will also need an Apple Developer ID, which is basically the same as your iTunes/App Store log in.  Its free, it just takes a couple minutes to set up.  To get the command line tools package, open Xcode and navigate to Xcode > Open Developer Tools > More Developer Tools..., which will launch a web browser.  Log in with your Apple Developer ID and proceed to download the latest version of Command Line Tools for Mountain Lion.  If you have any difficulties, more detailed instructions can be found on the Apple help page here http://developer.apple.com/library/mac/#documentation/DeveloperTools/Conceptual/WhatsNewXcode/Articles/xcode_4_3.html

Once you are done installing the command line tools you are finally ready to install MacPorts!  To install MacPorts, just grab the proper installer package from http://www.macports.org/install.php.  There are several different ways to install MacPorts, but I would recommend just using the installer package for your version of OSX.

Once you have run the installer package, you will need to open a terminal and update the MacPorts software list.  The command to do so is 

sudo port -v selfupdate

After you have run selfupdate, you can FINALLY install WINE!

sudo port install wine

Once you are done installing WINE, which will take a VERY long time (depending on your Internet connection speed and how fast your computer is) due to all of the dependencies it pulls in and compiles, you then need to tackle the job of preparing your WINE environment for running Office 2010.  The first thing you are are going to need to do is install another port called winetricks.  Install winetricks with the following command

sudo port install winetricks

Winetricks can also take a pretty long time to compile and install since it has a GTK frontend, so youll be pulling in a fair amount of GNOME packages too.

Once you have wine and winetricks installed, you can start preparing your wine environment.  Now, Id like to take a minute to expand on wine environments, because  there are quite a few caveats here that are not very well explained elsewhere.

Unless otherwise specified, WINE will use the default wine prefix (~/.wine).  When installing certain programs it is often a good idea to set up a separate environment.  You can specify which wine environment to use with the WINEPREFIX=~/.some_wine_prefix command.  The reason why you may want to do this is because the settings, overrides, tricks, hacks, workarounds and additional packages you absolutely NEED to use to make some programs work will flat out not work for some (if not most) other software.  Office 2010 is no exception.  Not only that, but Windows programs that need to be activated and/or registered (like Office) can often break after you install other programs, so it is in your best interest to establish a separate wine environment for big programs, and leave the default environment untampered with for the times when you just need to run some .exe file without installing it.
To establish a new wine environment (we will be using eg; ~/.office10 for the remainder of this tutorial), execute the following command

env WINEPREFIX=~/.office10 wineboot

This will set up a basic wine environment in /Users/your-username/.office10.  Once winecfg is done running, you can start cherry picking the packages you need to install in order to run Office 2010.

The packages you need can be installed using winetricks.  On Snow Leopard you can use the GUI frontend, but I had no luck with using the GUI on Mountain Lion, YMMV.  
The packages you need to install in order to run Office 2010 are


  • gdiplus
  • msxml6
  • dotnet20
  • riched20
  • corefonts
I would highly recommend just using the command line, because there are some additional steps you need to take to install some of these packages, specifically you will be redirected to manually download certain packages that cant be distributed freely and place them in the proper folder (eg; ~/Library/Caches/winetricks/dotnet20) and then rerun the last command.

to install these packages, execute the following commands one at a time, making sure to follow any additional instructions youre given

env WINEPREFIX=~/.office10 winetricks gdiplus
env WINEPREFIX=~/.office10 winetricks msxml6
env WINEPREFIX=~/.office10 winetricks dotnet20
env WINEPREFIX=~/.office10 winetricks riched20
env WINEPREFIX=~/.office10 winetricks corefonts

Once you are done installing all of these packages, execute the command

env WINEPREFIX=~/.office10 winecfg

Once the X11 server fires up and the the wine configuration window opens, go to libraries and set the following overrides to "native":  gdiplus, msxml6, riched20

Once you are done, you should FINALLY be able to run the Office 2010 installer without it encountering any more errors.

!!!NOTE!!!

And this is huge, I spent a couple days beating my head against the wall over this one.  If you are on Snow Leopard, the install should proceed and finish with success, but on Mountain Lion, the installer will fail without giving you any indication as to why, and I would assume that the same thing will happen on Lion too.  I kicked it around in my head for a couple of days and thought about what is different between Snow Leopard and Mountain Lion from a Microsoft perspective?

Answer:  the lack of Server Message Block (smb) file sharing protocol, aka "samba".

I believe that with the release of Lion, (I know its gone for sure by Mountain Lion) Apple did away with native SMB file sharing and implemented their own method of talking to Windows networks, which I believe is based on WebDAV.  In order to successfully install Office 2010, you will need to install SMB, which is thankfully a painless procedure with MacPorts.  Just execute the command

sudo port install samba3

Then once samba is installed, reboot your computer (just in case!  I wanted to be sure that I wouldnt run into any hangups over services not being started properly).  Then once you have rebooted, you can actually proceed to install Office 2010.  Now, it is very important that you select the wine prefix you spent all that time setting up.

env WINEPREFIX=~/.office10 wine /path/to/office10/setup.exe

Where you run the installer from doesnt really matter, but its best if there are no spaces anywhere in the path to where the .exe is located (eg; /Users/your-username/Downloads/Microsoft Office 2010/setup.exe).  Yes, you can technically escape the spaces with a backslash or enter the path inside quotes, but trust me you are only asking for headaches.

One big caveat here:  If you try to install Office 2010 in a given prefix and the installer fails for ANY REASON, you will never be able to install Office 2010 in that environment!   Every subsequent attempt to install will fail silently with unknown errors and youre just going to be angry.  So take heed, follow my instructions carefully and set up a proper environment before ever attempting to run the installer.

Once you FINALLY get through the installer and youve successfully set up Office 2010 on OSX, how do you use it?  Well, you can always fire up a terminal and execute a command like

env WINEPREFIX=/Users/your-username/.office10 wine /Users/your-username/.office/drive_c/Program Files/Microsoft Office/Office14/WINWORD.EXE

I dont know about you, but that seems a little tedious.  So what I did is I created some simple applications using Automator to open specific WINE applications.

Open up automator and create a new workflow.  Inside the workflow, add a shell script.  Change the prefix from /bin/bash to /bin/sh.

Then add the command for whatever program you want to run, like Excel.  There are four parts to this shell script in order for it to work properly with Automator.
The first thing you have to do is to change directories into the directory where your program is.  If you execute the program from outside its directory, there is a chance that it wont be able to find its  libraries and such so you need to be very specific and accurate with Automator.

cd /Users/your-username/.office10/drive_c/Program Files/Microsoft Office/Office14/

Then hit enter to go to a new line.  Shell scripts are read and executed one line at a time, so there is no need to use && or anything like that here.  The second part, despite the fact that you are already in the Office 2010 directory with all the exe and dll files is to establish  which wineprefix you are using.  You HAVE to be accurate, a tilde will not suffice when using an Automator script.  You have to use the absolute path to your wineprefix.

env WINEPREFIX=/Users/your-username/.office10

Then the third part is to add the absolute path to your WINE binary, which should be located at /opt/local/bin/wine

env WINEPREFIX=/Users/your-username/.office10 /opt/local/bin/wine 

and then the very last part is to tell WINE which binary you want to execute.  Once again, despite the fact that you are already in the working directory where your .exe files are, you still have to use the absolute path with Automator.  So if we are trying to open Excel, use the absolute path to EXCEL.EXE, keeping in mind that you need to escape spaces and paths are case sensitive

env WINEPREFIX=/Users/your-username/.office10 /opt/local/bin/wine
 /Users/your-username/.office10/drive_c/Program Files/Microsoft Office/Office14/EXCEL.EXE

And last but not least, and this part is EXTREMELY IMPORTANT!!!  Put an & after the very end of the command so that the program runs in the background.  Otherwise, you will never get past the splash screen and it will stay on "starting" indefinitely.  So, putting it all together now, the whole script will look like this
cd /Users/your-username/.office10/drive_c/Program Files/Microsoft Office/Office14/
env WINEPREFIX=/Users/your-username/.office10 /opt/local/bin/wine
 /Users/your-username/.office10/drive_c/Program Files/Microsoft Office/Office14/EXCEL.EXE &

Now go ahead and test your automator script.  If it opens up your program properly, then go ahead and save it as an application somewhere (I put mine in /Users/me/Applications).  That is it, you are done.  Repeat the process for any other Windows applications you want to create a launcher for.


Available link for download