Page 1 of 3 123 LastLast
Results 1 to 10 of 30

Thread: How to associate files with PlayOnLinux installed MS Office

  1. #1
    Join Date
    May 2005
    Location
    Indiana
    Beans
    1,933
    Distro
    Hardy Heron (Ubuntu Development)

    How to associate files with PlayOnLinux installed MS Office

    Preface: This is a howto, not a question.

    Today, after beating my brains out trying to install Office 2007 with Wine 1.4 in Precise, I ended up resorting to using PlayOnLinux. What I learned about PlayOnLinux is that it makes installing things a dream, but it makes the general usability of those things an absolute nightmare. When I had Office 2007 installed with Wine, I could easily set filetype associations in Nautilus to Word and Excel. When I installed Office 2007 in PlayOnLinux, it didn't leave any way to associate filetypes. Also, PlayOnLinux created nice shortcuts to the apps on the desktop, but it didn't create any gnome-desktop launchers that will show up in Dash in Unity or Gnome Shell.

    After a lot of hard work and headaches, I finally figured out how to do both of those things, so I thought I would share that experience for future reference, and for anyone else who might need it.

    When you are preparing to do this, be aware that you will have to create two separate .desktop files for each Office program (Word, Excel, etc.). The first section creates a .desktop file so that a new instance of Word can be launched from the Dash. The second section creates a second .desktop file for associating file types.

    Creating a .desktop launcher file

    This creates a .desktop file so that a new instance your Office programs can be launched from Dash.

    Open a terminal, and enter this command:
    Code:
    gnome-desktop-item-edit ~/.local/share/applications/ --create-new
    In the window that comes up, first enter a name for your launcher. For Microsoft Word, we'll enter Microsoft Word as the name. Then in the "Command" box, for Word 2007, we'll enter this code
    Code:
    playonlinux --run "Microsoft Word 2007"
    For Excel 2007, you would enter "Microsoft Excel 2007" leaving the quotes in it. For anything else, you just would put whatever app name shows up in the PlayOnLinux window, and put that name in quotes. After this, you can click on the icon and use the file browser to point it to whatever icon you want to use for that launcher.

    After doing this, your app launcher should show up by doing a Dash search.


    Associating files with MS Office that was installed with PlayOnLinux

    This creates a second .desktop file for associating your file types.

    Step 1 - creating a .desktop launcher for association
    Since PlayOnLinux installed apps don't show up in the "Open With" dialog in Nautilus, you have to create a custom command for Nautilus. This used to be easy to do with the GUI, but since they changed to Gnome 3 in 11.10, you can't do that anymore. Never fear, that's why we have the command line. Open a terminal, and cd to a folder that has a .doc or .docx file. Once you're in that folder, note the name of your Word document file, and type:
    Code:
    mimeopen -d filename.doc
    Of course you would type .docx if that's what type of file it is. When you type this, it will give you options of what you want the default app to be for that file. Enter whatever number says "Other" so that you can enter a custom command. For that custom command, enter the following for Word 2007:
    Code:
    playonlinux --run "Microsoft Word 2007" z:%f
    Note, that it will try to open the file with Word, and at this point it will not work. By the time you're done, it will work properly when you double click it in Nautilus.

    Now open up Nautilus, press Ctrl+H if hidden files aren't showing, and navigate to ~/.local/share/applications and find the .desktop launcher file with something like "playonlinux_userdefined" in the name. Change that name to something like Word.desktop. Now you can right-click on a .doc or .docx file, go to Properties, and go to the "Open With" tab, click "Show Other Applications" and find "Word.desktop" in the list. Now, that filetype is associated with Word, and you can go through all of those steps again substituting the right names for Excel and Powerpoint.

    Step 2 - making it work properly
    Unfortunately, what you just did won't work if there are spaces in the file or folder names. But we can fix that, too.

    Open Nautilus and navigate to ~/.PlayOnLinux/shortcuts. Double click on each of the shortcuts that were made for Word, Excel, and Powerpoint, and choose to Display the file in Gedit. At the end of the script, you should find this code:
    Code:
    $@
    Change that code for the following code in each shortcut script, and save the files.
    Code:
    "$(echo "$@" | sed -e 's:/*/:\\:g')"
    Make sure you leave the quotes in. That code will take the path and filename and convert any spaces to be readable by Word, Excel, or Powerpoint when you open the file.

    Since both desktop files will show up in a Dash search, I suggest not assigning an icon to this one to prevent confusion.

    Now, you should be able to navigate to any MS Office file in Nautilus, double click on it, and it will open properly.

    I'm not an expert, and this is just the findings of my experience. Hopefully it works for you, too.


    Edit: I found all of this information scattered all over the net, but I need to give credit to wojox for helping me fix a problem with the bash code I found for the shortcut script.
    Last edited by forrestcupp; May 3rd, 2012 at 12:46 PM.
    Today you are You, that is truer than true. There is no one alive who is Youer than You. - Dr. Seuss

  2. #2
    Join Date
    Jul 2011
    Beans
    4

    Re: How to associate files with PlayOnLinux installed MS Office

    This tutorial is very helpful indeed. Now I'm having Microsoft Office 2010 up and running with PlayOnLinux. I can use LibreOffice or Microsoft Office with a click of the mouse. Thanks a lot!

  3. #3
    Join Date
    May 2005
    Location
    Indiana
    Beans
    1,933
    Distro
    Hardy Heron (Ubuntu Development)

    Re: How to associate files with PlayOnLinux installed MS Office

    I'm glad it helped someone other than me!

    Maybe someday, they'll just change PlayOnLinux to do this stuff automatically.
    Today you are You, that is truer than true. There is no one alive who is Youer than You. - Dr. Seuss

  4. #4
    Join Date
    May 2011
    Location
    Israel
    Beans
    31
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: How to associate files with PlayOnLinux installed MS Office

    That worked great! Thank you very much!
    One and one and one is three.

  5. #5
    Join Date
    Oct 2011
    Beans
    1

    Talking Re: How to associate files with PlayOnLinux installed MS Office

    Brother Let me tell you this "You are AWESOME"

    It's Working................ COOL

  6. #6
    Join Date
    Feb 2009
    Beans
    15

    Re: How to associate files with PlayOnLinux installed MS Office

    Thank you, it works!

    But... just a couple of things:

    - If the new .desktop file that we've created doesn't include an icon, when you open an office document with it, it will appear with an invisible icon in the unity bar. In order to avoid this, you should include a line like this in each of the .desktop files:
    Code:
    Icon=/home/username/.PlayOnLinux//icones/full_size/Microsoft Word 2007
    (remember to replace the "Word" with "Excel" and "Powerpoint" when needed, and make sure that you change the username with your real username)

    - Because we told the shortcut to open the z:%f file, I receive an error every time I try to use that shortcut without specifying any file. (for example, If i use that shortcut in the Unity bar). Is there any way to avoid that?

  7. #7
    Join Date
    May 2005
    Location
    Indiana
    Beans
    1,933
    Distro
    Hardy Heron (Ubuntu Development)

    Re: How to associate files with PlayOnLinux installed MS Office

    Quote Originally Posted by whochismo View Post
    Thank you, it works!

    But... just a couple of things:

    - If the new .desktop file that we've created doesn't include an icon, when you open an office document with it, it will appear with an invisible icon in the unity bar. In order to avoid this, you should include a line like this in each of the .desktop files:
    Code:
    Icon=/home/username/.PlayOnLinux//icones/full_size/Microsoft Word 2007
    (remember to replace the "Word" with "Excel" and "Powerpoint" when needed, and make sure that you change the username with your real username)

    - Because we told the shortcut to open the z:%f file, I receive an error every time I try to use that shortcut without specifying any file. (for example, If i use that shortcut in the Unity bar). Is there any way to avoid that?
    I think you slightly misunderstood the HowTo. Because of what you said at the end, you actually have to create two desktop files. I've tried to think of a way around that, and you just have to do it because of the script error you're talking about.

    In the HowTo, the first section makes a plain .desktop file just for launching Word, etc., from Dash. That's the one you should set an icon for, and in my instructions, I just said to use the GUI to set that.

    The second section of the HowTo is for making another .desktop file that will include the script, and this one is for associating file types with Office. Since they will both appear in a Dash search, I recommend not assigning an icon to this file so it won't be confusing.

    Thanks for pointing out the confusion. I'll edit the first post to make it a little clearer.
    Today you are You, that is truer than true. There is no one alive who is Youer than You. - Dr. Seuss

  8. #8
    Join Date
    May 2011
    Beans
    6

    Re: How to associate files with PlayOnLinux installed MS Office

    Thank you very much. That was perfect.

  9. #9
    Join Date
    May 2012
    Beans
    1

    Re: How to associate files with PlayOnLinux installed MS Office

    forestcupp, your tutorial is thorough and it works flawlessly.

    thank you.


    here's another option using mimetypes:
    • just paste the whole thing into the terminal after installing MS Office with PlayOnLinux
    • works for 2010 & 2007
    • only sets Excel, Word, and/or Powerpoint as default application(s)
    • rewrites the main and context menu shortcuts
    • i wrote this for kubuntu but it should work for gnome,unity,yadda,yadda...
    • although, in Unity, user mimetypes are suppose to be set in ~/.local/share/applications/mimeapps.list, but whatever...
    • for mimetype info on other apps, go here http://filext.com/file-extension
    • There's a bug where PlayOnLinux might not double quote POWERPNT.EXE and $@ for Excel in ~/.PlayOnLinux/shortcuts/, so if you get an error, just manually do forestcupp's trick.

    Code:
    Word_mimetypes='application/msword;application/vnd.openxmlformats-officedocument.wordprocessingml.document;application/vnd.openxmlformats-officedocument.wordprocessingml.template;application/vnd.ms-word.document.macroEnabled.12;application/vnd.ms-word.template.macroEnabled.12;';Excel_mimetypes='application/vnd.ms-excel;application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;application/vnd.openxmlformats-officedocument.spreadsheetml.template;application/vnd.ms-excel.sheet.macroEnabled.12;application/vnd.ms-excel.template.macroEnabled.12;application/vnd.ms-excel.addin.macroEnabled.12;application/vnd.ms-excel.sheet.binary.macroEnabled.12;';Powerpoint_mimetypes='application/vnd.ms-powerpoint;application/vnd.ms-powerpoint;application/vnd.ms-powerpoint;application/vnd.ms-powerpoint;application/vnd.openxmlformats-officedocument.presentationml.presentation;application/vnd.openxmlformats-officedocument.presentationml.template;application/vnd.openxmlformats-officedocument.presentationml.slideshow;application/vnd.ms-powerpoint.addin.macroEnabled.12;application/vnd.ms-powerpoint.presentation.macroEnabled.12;application/vnd.ms-powerpoint.template.macroEnabled.12;application/vnd.ms-powerpoint.slideshow.macroEnabled.12;';echo ; echo -n '    Which year of Microsoft Office have you installed? (2010/2007) : '; read office_year; echo ; for i in $( ls ~/.PlayOnLinux/shortcuts | grep -owE '(Word|Excel|Powerpoint)' ); do echo '[Desktop Entry]
    Encoding=UTF-8
    Categories=Office;
    Comment=Microsoft Office '"$i $office_year"'
    Exec=/usr/share/playonlinux/playonlinux --run "Microsoft '"$i $office_year"'" z:%f
    Icon=~/.PlayOnLinux//icones/full_size/Microsoft '"$i $office_year"'
    InitialPreference=3
    Name=Microsoft '"$i $office_year"'
    MimeType='$(eval "echo \$${i}_mimetypes")'
    Type=Application' > ~/.local/share/applications/Microsoft\ "$i"\ "$office_year".desktop && sed --in-place 's/$@/$(echo "$@" | sed -e '\''s:\/*\/:\\\\:g'\'')/g' ~/.PlayOnLinux/shortcuts/Microsoft\ "$i"\ "$office_year" && echo '    Success - ' "$i" "$office_year" set as a default application; done; echo "    Done.\n";
    Last edited by 3ill; May 28th, 2012 at 01:05 PM.

  10. #10
    Join Date
    Jul 2009
    Beans
    571
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: How to associate files with PlayOnLinux installed MS Office

    Works like a charm!

    It's the super tutorial!
    It's OK, everything we know will become obsolete at some time.

Page 1 of 3 123 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •