0

My main operating system is Ubuntu (14.04 LTS), but sometimes I have to work on Windows as well. I use Microsoft Live Office and Google Docs very often. The problem is when I create some documents e.g. LibreOffice Writer and try to use them on Windows (OR OPPOSITE), I get problems very often, losing some formatting etc. Also .docx files need recovery very often on Ubuntu. I mean there are many little annoying details. How can I deal with them?

Is there any way I can create an Office document without any particular extension (e.g .docx .odt) so they will work on both systems without problems?

  • 6
    It's not the extension that gives you problems, it's the format. There's not one format that's native to all office suits. Try ing to work with one document in different office suits will result in some problems from time to time. Period. There's not much you can do about it. – Hinz Dec 19 '15 at 16:31
  • On Linux you can create names of files without extensions (since in Linux those are just for us humans to identify files). But @hinz is correct. The problem is the formatting of the files. Different office suits (ie. Libre+Open and MSO) are not 100% compatible). If you find something not working I would advice to file a bug against that feature.The "recovery" problem is most definitely something to report. – Rinzwind Dec 19 '15 at 16:47
3

It seems you are looking for better compatibility with Microsoft Office. Google Docs is used in the browser. So, this is perfectly compatible between Windows and Ubuntu. Libreoffice has versions for both Windows and Ubuntu, again perfect compatibility.

Office Online preserves Microsoft Office .docx and other document type formatting perfectly. Therefore, I posted this question in order to automate the following steps.

  1. Prepend this: https://view.officeapps.live.com/op/view.aspx?src=

  2. Append the URL of the Word document: https://dl.dropboxusercontent.com/u/4992179/My-Document.docx

  3. Final product: https://view.officeapps.live.com/op/view.aspx?src=https://dl.dropboxusercontent.com/u/4992179/My-Document.docx

I recommend following the steps at my forum post to keep MS Office formatting consistent in Ubuntu.

At times I receive a .docx file from a colleague that needs editing. I open it in LibreOffice to make my edits of the content (no formatting changes though) and save it. In LibreOffice the formatting will likely be different than if it were opened in MS Office. Then I open it using the Office Online script (posted below). In Office Online the formatting will be preserved, but with the recent edits I just made. Please note that if you open the same document more than once in Office Online, the second time you will need to change the file name by at least one character. The MS Office Online cache prevents it from detecting that it is indeed an updated document.

The script below can integrate into the context menu of any file manager. If you want to use terminal, you can do the following.

  1. Create a bin directory if you haven't yet in your home directory and move the script there.
  2. cd ~/bin
  3. Make the script executable chmod +x MS_Office_Online-Script
  4. Open a new terminal. MS_Office_Online-Script /path/to/document.docx

In general I would try to transition to using LibreOffice instead of MS Office. In fact, I hope this script will enable you to eliminate Windows altogether. ;)

#!/bin/bash

# Name:         Open in Microsoft Office Online
# Author:       (c) 2015 Glutanimate <https://github.com/Glutanimate/>
# Dependencies: dropbox, a web browser (e.g. firefox, chromium...)
# Installation: https://askubuntu.com/q/574252/81372
#
# License:      GNU GPLv3 (http://www.gnu.de/documents/gpl-3.0.en.html)
# Usage:        open_in_microsoft_office_online <file>

# Settings

DbPath="$HOME/Dropbox"
CopyToDb="yes"  # whether to copy file to public dropbox folder
                # in case it's not there already (no/yes)

# Variables

GuiIcon="dropbox"
GuiTitle="Open in Microsoft Office Online"
MsOfficeUrl="https://view.officeapps.live.com/op/view.aspx?src="

File="$1"
Filename="${File##*/}"

# Functions

gui_notify(){
  ## generic notification function
  notify-send -i "$GuiIcon" "$GuiTitle" "$1"
  echo "$1"
}

# Checks

## check if file selected
if [[ ! -f "$File" ]]; then
  gui_notify "Error: No file selected."
  exit 1
fi

## check if Dropbox running
if ! pgrep dropbox > /dev/null 2>&1; then
  gui_notify "Error: Dropbox isn't running."
  exit 1
fi

## check if Dropbox folder set correctly
if [[ ! -d "$DbPath" ]]; then
  gui_notify "Error: Can't find dropbox folder. Please set DbPath in script."
  exit 1
fi

# Main

## get public URL
DbPubUrl="$(dropbox puburl "$File")"

## optional: copy file to public dropbox folder if it isn't there
if [[ "$CopyToDb" = "yes" && "$DbPubUrl" = "Couldn't get public url: Unknown Error" ]]; then
  ## create public Dropbox folder if it doesn't exist
  [[ ! -d "$DbPath/Public" ]] && mkdir "$DbPath/Public"
  ## copy file to public folder, don't overwrite any existing file
  cp -n "$File" "$DbPath/Public/"
  ## wait for sync to complete
  SyncCounter="0"
  while dropbox filestatus "$DbPath/Public/$Filename" | grep syncing; do
    [[ "SyncCounter" = "0" ]] && gui_notify "Syncing file..."
    sleep 5
    ## wait a maximum of 10 minutes for sync to complete
    if [[ "$SyncCounter" -gt "120" ]]; then
      gui_notify "Error: Sync timeout. Exiting."
      exit 1
      break
    fi
    ((SyncCounter++))
  done
  ## get public URL
  DbPubUrl="$(dropbox puburl "$DbPath/Public/$Filename")"
fi

## check if public URL exists and open in Microsoft Office Online
if [[ "$DbPubUrl" != "Couldn't get public url: Unknown Error" ]]; then
  xdg-open "${MsOfficeUrl}${DbPubUrl}" > /dev/null 2>&1 &
  gui_notify "Opening document in Microsoft Office Online..."
else
  gui_notify "Error: Can't generate public Dropbox link from File."
fi 

Below is the script that I currently use. It is actually faster than the above script (see the "Wait for sync to complete." comment), but I took out some if statements and simplified it. Dropbox no longer has the Public folder for free accounts and discontinues it for paid ones on September 1, 2017. So, you'll need to use a different website service. You would adjust the URL in the script with your own web URL.

#!/bin/bash

# Name:         Open in Microsoft Office Online
# Author:       jbrock; Much thanks to Glutanimate <https://github.com/Glutanimate/>
# Dependencies: dropbox, a web browser (e.g. firefox, chromium...)
# Installation: http://askubuntu.com/q/574252/81372
# License:      GNU GPLv3 (http://www.gnu.de/documents/gpl-3.0.en.html)
# Usage:        open_in_microsoft_office_online <file>

# Variables
pub_path="$HOME/Dropbox/Public"
file="${1##*/}"

# Copy to Dropbox/Public directory.
cp -n "$1" "$pub_path"

# Wait for sync to complete.
while dropbox filestatus "$pub_path/$file" | grep -q syncing; do true; done

# Open in browser. (Get public URL is broken: 6 Sept. 2016)
exo-open "https://view.officeapps.live.com/op/view.aspx?src=https://dl.dropboxusercontent.com/u/4992179/$file" > /dev/null 2>&1 &

# Remove file from Public folder.
# This last part is optional. You probably want to remove your document from a public directory.
# I use this function with Xfce. I am not sure about other desktop environments.
#sleep 15
#trash () {
#dir="$HOME/.local/share/Trash/files/"
#if ! [ -d "$dir" ]; then
#   mkdir "$dir"
#fi
#mv "$@" "$dir"
#}
#trash "$pub_path/$file"
0

It sounds like you have an old version of libreoffice, if you don't have latests libreoffice 5 why don't you upgrade?

https://www.libreoffice.org/download/libreoffice-fresh/

I haven't had that kind of problem in a long time specially with .doc or .docx documents they have almost 100% compatibility

0

If no other, more obvious ways help, one of the last resorts is the use of pdf, which is portable between OSs. But, pdf is not normally editable, so one needs to use copy and paste. This may ruin formatting too sometimes, but you may want to keep this solution in mind and try it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.