Page 1 of 1
[Solved] Switching between Calc and Writer Windows
Posted: Fri May 12, 2017 1:19 pm
by sanmahaan
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.
Re: Switching between Calc and Writer Windows
Posted: Fri May 12, 2017 1:49 pm
by Villeroy
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.
Re: Switching between Calc and Writer Windows
Posted: Fri May 12, 2017 2:21 pm
by sanmahaan
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.
Re: Switching between Calc and Writer Windows
Posted: Fri May 12, 2017 2:30 pm
by Zizi64
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
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.
viewtopic.php?f=45&t=59932
You can activate one or other document by the
API function. See the code snippets on the linked forum-page.
You MUST study the API (Application Programming Interface) functions.
Re: Switching between Calc and Writer Windows
Posted: Fri May 12, 2017 4:04 pm
by sanmahaan
Thank you Zizi64..Based on your input code and the links, I was able to work out and resolve my issue. Thanks once again.
Re: [Solved] Switching between Calc and Writer Windows
Posted: Sat May 13, 2017 12:22 am
by Sébastien C
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!
Code: Select all
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