Resizing a File Picker Dialog with Macro

I am using a file picker dialog in a few spreadsheet projects and I am trying to figure out how to resize the dialog in the macro that launches the file picker. I want to stored the size and position and every time that it gets called it should be resized and positioned according to the saved values. Attached is a sandbox file that I made to figure it out.

I am using a Window listener to do the resizing, but for some reason the FileDialog.Window property is not accessible. I figured out that if I add an Xray command above the .Window line then it works fine. I think it has to do with the Context but I don’t understand what to do different.

I am using LO v5 on a Linuz OS.

Can someone please provide pointers on this? I would really appreciate knowing why this attached file throws an error.

FilePicker Resizing.ods (10.1 KB)

Hi,

I would be surprised, if the FileDialog.Window exists before you call FileDialog.execute().
To be sure the file dialog window really exists it is better to work with the TopWindowListener here.

Good luck,

ms777

Global oList as Object
Global oToolkit as Object

sub main
...
oToolkit = CreateUnoService("com.sun.star.awt.Toolkit")
oList = CreateUnoListener("TopWGeneric_", "com.sun.star.awt.XTopWindowListener")
oToolkit.addTopWindowListener(oList)
...
FileDialog = CreateUnoService("com.sun.star.ui.dialogs.FilePicker")
...
end sub

sub TopWGeneric_windowOpened(e as Object)
	if HasUnoInterfaces(e.source, "com.sun.star.awt.XDialog") then
		if InStr(e.source.title, "Select a file")>0 then
			e.source.setPosSize(0, 0, 1000, 700, com.sun.star.awt.PosSize.SIZE)
			oToolkit.removeTopWindowListener(oList)
		endif
	endif 
end sub

sub TopWGeneric_windowClosing(e as Object)
end sub

sub TopWGeneric_windowClosed(e as Object)
end sub

sub TopWGeneric_windowMinimized(e as Object)
end sub

sub TopWGeneric_windowNormalized(e as Object)
end sub

sub TopWGeneric_windowActivated(e as Object)
end sub

sub TopWGeneric_windowDeactivated(e as Object)
end sub

Thanks to someone else’s input, the code that I shared actually works if the ‘setcontrolproperty’ line that hides the Help button is moved above the 'filedialog.Window command. Not sure what difference that makes ??

Sorry, LO is not installed on this PC or I would share a better example.