Scripting problem: converting folder to folderS

Started by ubacher, March 30, 2015, 11:32:16 AM

Previous topic - Next topic

ubacher

I have problems with the following code:
Quote

Dim to_folders As New IMFolders  ' NEW causes: server can not create object
   Dim fld As IMFolder
   Set fld = Database.Folders("D:\Foto Cache")
   Set to_folders(1) = fld          ' convert folder to folders since needed in next step
   Set to_folders = Database.SelectFoldersDialog ( to_folders,)

the NEW statement for IMFolders causes an error message server can not create object
Is this a bug? Do I need it?
I think without the new my conversion from folder fldto folders to_folders will not work.
Or I do something wrong. Help appreciated.

Mario

You cannot create a folders collection. This class is declared as non-createable by intention.
IMFolders is only used to retrieve data from the database.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

ubacher

This leaves the question how to correctly convert a folder into folders -
since I need to (want to) put a starting folder for the SelectFoldersDialog.

i.e. I have a folder - it is the starting folder I want. But SelectFoldersDialog accepts only a IMFolders argument.

Mario

The idea is to use the methods SelectedFolders to get an initialized folders collection. There is no way you can create a folders collection from a script and just stuff arbitrary folders in to make up some sort of initial selection. If the available methods are not sufficient, you can only start with an empty selection. As always, if you want changes or addition, add a feature request. I don't plan to make changes to scripting soon, though. Especially since I already added several new methods for the next release, some for your purposes I think. So now I will concentrate on other things.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

JohnZeman

Quote from: ubacher on March 30, 2015, 02:29:33 PM
This leaves the question how to correctly convert a folder into folders -
since I need to (want to) put a starting folder for the SelectFoldersDialog.

i.e. I have a folder - it is the starting folder I want. But SelectFoldersDialog accepts only a IMFolders argument.

I'm on my lunch break now and don't have the time now to study what you're doing but maybe the attached script will give you a few ideas.



[attachment deleted by admin]

ubacher

I found the way to do it:
Instead of database.SelectFoldersDialog I now use Application.SelectFolderDialog
So there is no need to use IMFolders.

Thank you John - your script gave me the hint.