Browse for a folder

sunctsunct Member Posts: 72
Hi,

I need to browse and open a folder to store a file. I am using the automation 'Microsoft Shell Controls And Automation'.Shell for this purpose.

It works well when I select the folder and click Ok. However if I browse and then click cancel, i am getting an error message

Below is the code :


IF ISCLEAR(ShellControl) THEN
CREATE(ShellControl);
Folder := ShellControl.BrowseForFolder(0,'',0);
FolderItems := Folder.Items();
FolderItem := FolderItems.Item;
"Archived Filename" := FORMAT(FolderItem.Path);
CLEAR(ShellControl);

Name DataType Subtype Length
ShellControl Automation 'Microsoft Shell Controls And Automation'.Shell
Folder Automation 'Microsoft Shell Controls And Automation'.Folder3
FolderItems Automation 'Microsoft Shell Controls And Automation'.FolderItems3
FolderItem Automation 'Microsoft Shell Controls And Automation'.FolderItem2

Anyone has a solution?

Thanks
Regards,
Sunil

Answers

  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    Try using the solution of 'janpieter' in the thread: Get a Folder (Not Reg. new DLLs)
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • sunctsunct Member Posts: 72
    Thanks Luc Van Dyck !

    It worked well.

    Regards
    Regards,
    Sunil
  • nayenaye Member Posts: 4
    IF ISCLEAR(ShellControl) THEN
    CREATE(ShellControl);
    Folder := ShellControl.BrowseForFolder(0,'',0);
    IF NOT ISCLEAR( Folder ) THEN BEGIN
    FolderItems := Folder.Items();
    FolderItem := FolderItems.Item;
    "Archived Filename" := FORMAT(FolderItem.Path);
    END;
    CLEAR( ShellControl );
    CLEAR( Folder );
    CLEAR( FolderItems );
    CLEAR( FolderItem );
Sign In or Register to comment.