Create a new document minimized

Hello everyone,

Is there a possibility of creating a new document (calc or writer) using a macro and automatically opening it as a minimized window? I could have sworn I saw a property in the “.uno:open” dispatch call for precisely this purpose, but I cannot find it neither here nor on OO forum.

I looked at the git reference for this command, but no clue (unless I am looking at a wrong command all together):

SfxVoidItem Open SID_OPENDOC
2818 (SfxStringItem URL SID_FILE_NAME,SfxStringItem FilterName SID_FILTER_NAME,SfxStringItem OpenFlags SID_OPTIONS,SfxStringItem Password SID_PASSWORD,SfxStringItem FilterOptions SID_FILE_FILTEROPTIONS,SfxInt16Item Version SID_VERSION,SfxStringItem Referer SID_REFERER,SfxStringItem SuggestedSaveAsDir SID_DEFAULTFILEPATH,SfxStringItem SuggestedSaveAsName SID_DEFAULTFILENAME)
2819 [
2820 AutoUpdate = FALSE,
2821 FastCall = FALSE,
2822 ReadOnlyDoc = TRUE,
2823 Toggle = FALSE,
2824 Container = TRUE,
2825 RecordAbsolute = FALSE,
2826 RecordPerSet;
2827 Asynchron;
2828
2829 AccelConfig = TRUE,
2830 MenuConfig = TRUE,
2831 ToolBoxConfig = TRUE,
2832 GroupId = SfxGroupId::Application;
2833 ]

I think there isn’t the parameter for minimized window in LoadComponentFromUrl, but it is possible to open hidden document, minimize it and show.

Sub loadDocMinimized
	dim oDoc as object, oContainer as object, args(0) as new com.sun.star.beans.PropertyValue
		args(0).Name="Hidden"
		args(0).Value=true
	oDoc=StarDesktop.LoadComponentFromUrl("private:factory/swriter", "_blank", 0, args())
	oContainer=oDoc.CurrentController.Frame.ContainerWindow
	with oContainer
		.isMinimized=true 'minimize window
		.Visible=true 'show window
	end with
End Sub
2 Likes

Thank you very much @KamilLanda . Precisely what I was looking for.

I tested your ( KamilLanda) code with V7.5.3.2 and made some strange observations.

  1. The “untitled” numbering skipped the next index.
  2. The new window - finally sized up - showed an incorrect security warning.
  3. This warning was omitted if the new window was created visible first, and set to .isMinimized subsequently.

Did you observe this too?

No I have not tried it yet at all. I will later on in the day, and report back.

@Lupp Without any problem at me:
“untitled” titles numbered normally (in Czech: Bez názvu 1.odt, Bez názvu 2.odt etc.) and no warnings.

Version: 7.6.0.1 (X86_64) / LibreOffice Community
Build ID: 776eaf34564cbf3f034a0ba1fd1d5c32ff9ccf1c
CPU threads: 4; OS: Windows 10.0 Build 19045; UI render: Skia/Raster; VCL: win
Locale: cs-CZ (cs_CZ); UI: cs-CZ
Calc: CL threaded Jumbo

7.6.0.0.beta1 under Win 10 doesn’t show the mentioned issues for me, too.

One not yet mentioned issue is there anyway:
If you insert the code into a module of the local (App, MyMacros) Standard library, you can’t run it from the StartCenter successfully.
(Seems to be related to the problem discussed here.)
LibreOffice (like Staroffice, OOo, AOO) refuses to run without any visible instance of something (a document, the StartCenter, the Basic IDE).

1 Like

@Lupp: running from StartCenter also isn’t possible at me :-(.

After closing all the tasks in Windows pertaining to Libreoffice and starting only one application (in my case Calc) and subsequently the basic IDE, I invoked the command which created a new instance of Writer… it had “Untitled 2” as a title, and then the following were 3, 4, 5 etc…

No errors, no sec warnings, etc…

Version: 7.5.2.2 (X86_64) / LibreOffice Community
Build ID: 53bb9681a964705cf672590721dbc85eb4d0c3a2
CPU threads: 16; OS: Windows 10.0 Build 22621; UI render: Skia/Vulkan; VCL: win
Locale: en-CA (en_CA); UI: en-US
Calc: threaded