[Solved] Switching between Calc and Writer Windows

Creating a macro - Writing a Script - Using the API

[Solved] Switching between Calc and Writer Windows

Postby sanmahaan » Fri May 12, 2017 1:19 pm

Hello,
I wish to switch between the open documents window of CALC and WRITER using macros in libreoffice.
I have searched for quite a while, but am not even close.
I have a big list of things to do after this step.
Request the code for the same.
Thanks in advance.
Last edited by sanmahaan on Fri May 12, 2017 4:05 pm, edited 1 time in total.
Libreoffice 4.0.2.2 on LINUX
sanmahaan
 
Posts: 12
Joined: Wed May 10, 2017 3:53 pm

Re: Switching between Calc and Writer Windows

Postby Villeroy » Fri May 12, 2017 1:49 pm

sanmahaan wrote:I have a big list of things to do after this step.

And you are going to ask us for every little item on that list? Forget it.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 16.04, OpenOffice 4.x & LibreOffice 5.x
User avatar
Villeroy
Volunteer
 
Posts: 24257
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Switching between Calc and Writer Windows

Postby sanmahaan » Fri May 12, 2017 2:21 pm

Dear Villeroy...I have seen your helpful responses in many posts...was expecting an extension of the same.
I am trying very hard to implement my ideas in Libreoffice, which I have had to switch over to recently, and trying to solve things myself.. (The big list is for me ! ) .
Also will be thankful if someone could suggest some study materials
to understand the syntax of the despatchers, UNO, et al.
Hope for helpful responses from this forum for my genuine requests.
Libreoffice 4.0.2.2 on LINUX
sanmahaan
 
Posts: 12
Joined: Wed May 10, 2017 3:53 pm

Re: Switching between Calc and Writer Windows

Postby Zizi64 » Fri May 12, 2017 2:30 pm

I wish to switch between the open documents window of CALC and WRITER using macros in libreoffice.


It is depend on the fact, how you opened those documents. If you open the documents by macro, then you can use the references
Code: Select all   Expand viewCollapse view
oDoc_A = stardesktop.loadComponentFromURL(sURL_1,"_blank",0,array()
oDoc_B = stardesktop.loadComponentFromURL(sURL_2,"_blank",0,array()

what you used at the opening procedure.
https://forum.openoffice.org/en/forum/v ... 45&t=59932

You can activate one or other document by the
Code: Select all   Expand viewCollapse view
StarDesktop.setActiveFrame(...
API function. See the code snippets on the linked forum-page.

You MUST study the API (Application Programming Interface) functions.
Tibor Kovacs, Hungary; LibreOffice4.4.7 on Win7x64Prof.
And the portable versions: LO3.3.0-LO5.4.1 and AOO4.1.3
Please, edit the topic's initial post, and add the word "[Solved]" at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
 
Posts: 5786
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Switching between Calc and Writer Windows

Postby sanmahaan » Fri May 12, 2017 4:04 pm

Thank you Zizi64..Based on your input code and the links, I was able to work out and resolve my issue. Thanks once again.
Libreoffice 4.0.2.2 on LINUX
sanmahaan
 
Posts: 12
Joined: Wed May 10, 2017 3:53 pm

Re: [Solved] Switching between Calc and Writer Windows

Postby Sébastien C » Sat May 13, 2017 12:22 am

Hello everybody
Zizi64 wrote:[...] If you open the documents by macro [...]

You can have some document opened by hand.
Open some documents.
Try this code bellow.
Enjoy!
:D
Code: Select all   Expand viewCollapse view
Sub activateOpenFiles As String
Dim fileName(255) As String
Dim    files(255) As Object
Dim   myDocuments As Object, theCollection As Object
Dim     activate As Integer,             i As Integer, j As Integer

theCollection = starDesktop.components.createEnumeration
             i = 0
      activate = 0

On Error Goto Next_1:                                                     ' In order to avoid pseudos empty windows.
While theCollection.hasMoreElements
  myDocuments = theCollection.nextElement
                                                                           ' Avoids the macro IDE and help windows.
  If ((  len(myDocuments.url    ) <> 0                     ) And _
      ( left(myDocuments.url, 20) <> "vnd.sun.star.help://") _
     ) Then
             i = i + 1
      files(i) = myDocuments
   fileName(i) = convertFromUrl(myDocuments.url)

   Next_1:
  End If
Wend

If (i >= 0) Then                                                          ' The opposite happens when no file is opened.
  Redim Preserve fileName(i)                                               ' Resize the table.
  For j = 1 to i
   If msgBox ("Activate:" & chr(13) & fileName(j), 36, "Activation") = 6 Then
    activate = j
    Exit For
   End If
  Next j
End If

If activate Then files(activate).currentController.frame.getContainerWindow.setFocus
End Sub
LibreOffice 5.x under GNU-Linux Mageia 5.0 and M$-W XP
User avatar
Sébastien C
 
Posts: 29
Joined: Mon Jan 04, 2010 5:06 pm
Location: Meymac, France


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 9 guests