Wednesday, September 15, 2010

MS Office in Linux

In the newer versions of wine is incredible easy to install the versions of MS Office prior to 2007, but after doing that I had some little trouble on how to make KDE use the MS Office Applications to correctly open a MS Office document when I click on it.

Well, the answer, as usually happens in Unixes, come as the form of a script.

Actually, two scripts for each MS Office application, on when you call it via shell and the other to be used exclusively when it is called by KDE.

Here is the one to be used by the KDE configuration, I usually place it under /usr/local/bin/winword-gui, and here are its contents:

#!/bin/bash
FILENM=$( basename "$@" )
UNXDIR=$( dirname "$@" )
WINDIR=$( echo $UNXDIR | sed 's@\/@\\@g' )
DOCPTH="Z:$WINDIR\\$FILENM"
/usr/bin/wine "C:\Program Files\Microsoft Office\Office12\WINWORD.EXE" "$DOCPTH" &

After creating this file you just right click on some .doc file in KDE and go "Open with -> Other" and select the file you created.

And, if you want to call it via shell, you can have this other script named /usr/local/bin/winword:

#!/bin/bash
/usr/bin/wine "C:\Program Files\Microsoft Office\Office12\WINWORD.EXE" "$@" &

Obviously depending on your wine configuration and office installation you need to change the last line of both scripts.

It could also be done in just one script, but since I am so lazy I prefer to just let it like this.

For the other MS Office applications, you create the same scripts but change the last line for the program you want (EXCEL.EXE, POWERPNT.EXE or whatever).

No comments: