Close all opened Writer documents

Java, C++, C#, Delphi, ??? - Using the UNO bridges

Close all opened Writer documents

Postby xsintill » Thu Mar 22, 2012 11:38 am

I am trying to close all opened writer documents. I thought I had a solution but when i also had a calc spreadsheet open the code would close the opened spreadsheet also. How do i distinguish between components so i only close writer components. Code so far:
Code: Select all   Expand viewCollapse view
  lComponents, lDocument: OleVariant;
  lComponents := FDesktop.GetComponents.CreateEnumeration;
  while lComponents.hasMoreElements do
    lDocument := lComponents.NextElement;
//FDesktop is created like so
FDesktop := FLibreOffice.createInstance('');
ooo 3.3
Posts: 1
Joined: Mon Mar 12, 2012 4:34 pm

Re: Close all opened Writer documents

Postby FJCC » Thu Mar 22, 2012 6:29 pm

Something like this (written in Basic) might work
Code: Select all   Expand viewCollapse view
Enum = StarDesktop.getComponents.createEnumeration()
While Enum.hasMoreElements()
   Doc = Enum.nextElement()
   If Doc.Identifier = "" Then
   End If
Windows 10 and Linux Mint, since 2017
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Posts: 7885
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Return to External Programs

Who is online

Users browsing this forum: No registered users and 2 guests