Opening the same file in two windows w/ Command Line Switch

Is there a way to do this currently? It seems like in every case, trying to open the same document twice brings focus to the currently open version of that document. I know the --view command line switch creates a read only copy of a document and opens that… but it seems it can only be opened once.

Any ideas?

Two alternatives:

  • Use a script to create a temporary copy of the file, and then open both the original and the copy.
  • Install both LibreOffice and Apache OpenOffice, and then open in each.

EDIT:

Now I see your other question at Multiple views of same document and understand what you are trying to do. It would have been helpful to include that link in your question.

Write a macro that calls Window → New Window and then call it from the command line.

EDIT 2:

To do this, put the following code under My Macros.

Sub NewWindow
    frame = ThisComponent.CurrentController.Frame
    dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
    dispatcher.executeDispatch(frame, ".uno:NewWindow", "", 0, Array())
End Sub

Then for example, enter this command to open the document called “Untitled 1.odt”.

soffice macro:///Standard.Module1.NewWindow "Untitled 1.odt"

The result on my system is two side-by-side windows.

two windows side by side

Awesome Macro. That should be good to know. I didn’t link the question because the question wasn’t mine and although I commented on it to highlight the answer supplied didn’t solve that user’s problem, what I’m actually trying to achieve is a bit different. I work with huge displays. So it would be nice to open a document many times and place it on different locations on the wall. I use a program to invoke other programs to display on the wall. So a command line switch is really what I’m after.

That said… this is an awesome answer for those looking to view two parts of the same document. Thanks for such a detailed response.

Also I’ve written a “LibreOfficeWrapper” exe which takes in cmd line switch args and the document as the last arg and it creates a read only copy in a folder in windows temp and opens it. When soffice.bin closes, it deletes the copy. I’m going to keep working on it but I requested a cmd line switch on bugs. Until a perm sol, if anyone wants this, let me know.

I’m afraid I have no idea why anyone would want that feature, but it might be a good idea to add your own answer in case someone else wants the same thing. You could even attach the .exe file after renaming it. However, downloading an .exe file from a site like this is risky. Someone could post a virus instead.

Maybe it can be added to the LO extensions site? May need the source code to, but I suppose they run a virus check before hosting.
https://www.libreoffice.org/discover/templates-and-extensions/

The fact that you can’t open the same file in two windows, indeed two apps (Writer and Calc), without resorting to trickery is rather embarrassing honestly. Google sheets can do this with no issue.

One solution is here.