Start Macro from Hidden writer document

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
Touf2638
Posts: 14
Joined: Tue Aug 20, 2019 4:21 pm

Start Macro from Hidden writer document

Post by Touf2638 »

Hello,
I launch a macro from .net application in a writer document to generate a QRCode. My problem is I need to launch document hidden and when document is hidden, macro seems unreach document.
When I start with hidden=false it works fine.

Is there a way to refer thiscomponent to an hidden document ?
Thanks
OpenOffice 6.2 on Windows 10
JeJe
Volunteer
Posts: 2764
Joined: Wed Mar 09, 2016 2:40 pm

Re: Start Macro from Hidden writer document

Post by JeJe »

Have you tried hiding it by positioning it off screen (by setting the window x value to minus the width for example) instead of not visible?

Edit: another alternative would be to hide it behind another open window... perhaps by making it minimum size and the other open window a topmost window. You may be able to use Api calls to change the window style so it doesn't appear in the Windows taskbar.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Touf2638
Posts: 14
Joined: Tue Aug 20, 2019 4:21 pm

Re: Start Macro from Hidden writer document

Post by Touf2638 »

It's a good idea. I will look how change position of writer application if it is possible.
OpenOffice 6.2 on Windows 10
Touf2638
Posts: 14
Joined: Tue Aug 20, 2019 4:21 pm

Re: Start Macro from Hidden writer document

Post by Touf2638 »

I have try to change position but I need to open document before change. So I see application then I see my change...
So I need to find and other way. Any idea ?

Cod eto change position if somebody need

Code: Select all

                Dim vFrame As Object, intXPos As Integer, intYPos As Integer, intHeight As Integer, intWidth As Integer
                vFrame = Document.getCurrentController.getFrame()
                vWindow = vFrame.getContainerWindow()
                intXPos = 6000
                intYPos = 6000
                intHeight = 1
                intWidth = 1
                vWindow.setPosSize(intXPos, intYPos, intWidth, intHeight, unoidl.com.sun.star.awt.PosSize.POSSIZE)
OpenOffice 6.2 on Windows 10
Touf2638
Posts: 14
Joined: Tue Aug 20, 2019 4:21 pm

Re: Start Macro from Hidden writer document

Post by Touf2638 »

If it's possible to show and hidden document, it can works but I don't know how show a document open with hidden property
OpenOffice 6.2 on Windows 10
Touf2638
Posts: 14
Joined: Tue Aug 20, 2019 4:21 pm

Re: Start Macro from Hidden writer document

Post by Touf2638 »

Ok i find Document.currentController.Frame.ContainerWindow.setVisible(True)
So I open document hidden, I change position out of screen then I set visible to true.
It works.
At the end I do reverse because if you let with parameters out of screen, when you launch manually open office it keep this parameters.
Thanks
OpenOffice 6.2 on Windows 10
User avatar
RoryOF
Moderator
Posts: 34586
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Start Macro from Hidden writer document

Post by RoryOF »

If the visible/hiding of the document is too obtrusive, you might experiment with making it visible but minimised.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
Post Reply