Thursday, February 18, 2010

Open Word, Excel und PDF documents with wine

Normally you don't install (ms|open)-office under wine.
You rather have the full openoffice directly installed under linux.

To allow windows apps to open the files with the native openoffice applications you can do the following:

- Create a registry file containing your associations per application

For example

REGEDIT4
[HKEY_CLASSES_ROOT\.doc]
@="docfile"

[HKEY_CLASSES_ROOT\docfile\shell\open\command]
@="c:\\ooffice.exe %1"


[HKEY_CLASSES_ROOT\.xls]
@="xlsfile"

[HKEY_CLASSES_ROOT\xlsfile\shell\open\command]
@="c:\\ooffice.exe %1"

[HKEY_CLASSES_ROOT\.pdf]
@="pdffile"

[HKEY_CLASSES_ROOT\pdffile\shell\open\command]
@="c:\\pdfreader.exe %1"


Then import this with regedit.exe
Now create the helper applications under C:\ of your wine installation.

For example: ooffice.exe (Make sure it is executable chmod a+x ooffice.exe)

!/bin/sh
ooffice "`winepath -u "$*"`"


or for pdf:

#!/bin/sh
acroread "`winepath -u "$*"`"


What happens:

1. In the registry you tell windows what app to start for the corresponding file type
2. In the helper file ooffice.exe you start the native linux application
The helper application winpath converts a windows path into the corresponding linux path

No comments:

Post a Comment