[Solved] FileOpenDialog multiselect does not work on Win7

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
gzoo
Posts: 5
Joined: Mon Jun 12, 2017 1:58 pm

[Solved] FileOpenDialog multiselect does not work on Win7

Post by gzoo »

I wrote a script using FileOpen dialog, and wanted to use multiselection. It worked out on XP, but does not on Win7/64bit.
I can not see the reason.
The behaviour is: dialog opens, but does not allow multiselect at all, only single. Even I set '.setMultiSelectionMode(True)'.
Last edited by Hagar Delest on Tue Jun 13, 2017 8:03 am, edited 1 time in total.
Reason: tagged [Solved].
OpenOffice 4.1.3 on Windows 7 64bit
User avatar
RoryOF
Moderator
Posts: 34588
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: VBA FileOpenDialog multiselect does not work on Win7

Post by RoryOF »

We need to see the code involved.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
gzoo
Posts: 5
Joined: Mon Jun 12, 2017 1:58 pm

Re: VBA FileOpenDialog multiselect does not work on Win7

Post by gzoo »

Code: Select all

Function OpenFileDialogKep(byRef files() as String) as Integer
	Dim oFilePicker As Object
	Dim sFiles As Object
	
	REM file dialog
	oFilePicker = CreateUnoService( "com.sun.star.ui.dialogs.FilePicker" )
	REM set filter
	oFilePicker.AppendFilter( "All files (*.*)", "*.*" )
	oFilePicker.AppendFilter( "Opera kiíró KEP fájl", "*.KEP" )
	oFilePicker.AppendFilter( "Opera kiíró TXT fájl", "*.TXT" )	
	oFilePicker.SetCurrentFilter( "Opera kiíró KEP fájl" )
	'oFilePicker.setDefaultName(defaultname)
	oFilePicker.setTitle("Kép fájl megnyitása")
	oFilePicker.setMultiSelectionMode(True)
		
 	If oFilePicker.execute() Then
    	sFiles = oFilePicker.getFiles()
		If Ubound(sFiles) = 0 Then
			ReDim Preserve files(2)
			files(0) = DirectoryNameoutofPath(sFiles(0), "/")
			files(1) = FileNameoutofPath(sFiles(0), "/")
			OpenFileDialogKep = 1
		Else
			ReDim Preserve files(Ubound(sFiles))
    		For i = 0 to Ubound(sFiles())
      			files(i) = sFiles(i)
      		Next i
   			OpenFileDialogKep = Ubound(sFiles())
     	End If
    Else
    	OpenFileDialogKep = 0
   End If
End Function
I just went back to Xp, import the script, run. It definetly allows multiselect and behaves as intended under XP. But I am not able to select more than 1 file under Win7/64.

Sorry, I found that, I use AOO 4.1.3 under Win7, and AOO 4.1.2 under XP. Might it be a difference?
OpenOffice 4.1.3 on Windows 7 64bit
User avatar
RoryOF
Moderator
Posts: 34588
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: VBA FileOpenDialog multiselect does not work on Win7

Post by RoryOF »

There is discussion on a similar topic at
viewtopic.php?f=20&t=79058
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
gzoo
Posts: 5
Joined: Mon Jun 12, 2017 1:58 pm

Re: VBA FileOpenDialog multiselect does not work on Win7

Post by gzoo »

Thank you for the information. I read the thread, and it is not similar...

I can get data out from open dialog. And the same script works well under XP.
But it does not work well under Win7/64

The difference is: file open dialog pops up, I can see the file list, but I am not able to select more than one file.
I tried to move cursor over multiple names during mouse button pressed, as usual. Only one file is selected.
I also tried to used SHFT+arrows, with same result.

And I updated AOO from 4.1.2 to 4.1.3 under XP, script works well under newer version of AOO too.
But not under Win7/64.
OpenOffice 4.1.3 on Windows 7 64bit
User avatar
Villeroy
Volunteer
Posts: 31270
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: VBA FileOpenDialog multiselect does not work on Win7

Post by Villeroy »

On a Linux/Gnome system I can select multiple files in the system file picker but the returned array contains only one element. Seems to be a bug.
The problem does not show up when you use the native office file picker (Tools>Options>General>Use Office dialog boxes)

Similar problem: viewtopic.php?f=20&t=86403&p=403950&hil ... er#p403938
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
gzoo
Posts: 5
Joined: Mon Jun 12, 2017 1:58 pm

Re: VBA FileOpenDialog multiselect does not work on Win7

Post by gzoo »

I can not write more clear...
The same script does everithing right under XP.
But I am not able to select more than one file in file opening dialog under Win7.
So, nothing to do with how to pass data, like filenames from file open dialog.
OpenOffice 4.1.3 on Windows 7 64bit
User avatar
Villeroy
Volunteer
Posts: 31270
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: VBA FileOpenDialog multiselect does not work on Win7

Post by Villeroy »

It has something to do with modern tool kits and old ones.

Recent Gnome fails
Recent Windows fails
XP works
Native AOO works

The last one can be switched on in any case. At least it works with AOO 4.1.3 on Linux where it fails with the Gnome tool kit.

LibreOffice has modified the file picker service.
It provides getSelectedFiles() with one full URL per selected file. This works with native LO dialogs and the Windows 10 tool kit as well.

I doubt this will ever be fixed in AOO since AOO is not under active development anymore.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
gzoo
Posts: 5
Joined: Mon Jun 12, 2017 1:58 pm

Re: VBA FileOpenDialog multiselect does not work on Win7

Post by gzoo »

Villeroy

I just tried to change, wich fileopen dialog should be used based on your previous post.
It does help.

Thank you
OpenOffice 4.1.3 on Windows 7 64bit
Post Reply