Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: M1TO on December 13, 2022, 09:21:43 pm
-
Hi.
I know how to get a file name including the path with Repository.GetProjectInterface().GetFileNameDialog(). But is there a way select a folder instead of a file as input for the script?
-
I do this in my FileSystemFolder class in VBScript: https://github.com/GeertBellekens/Enterprise-Architect-VBScript-Library/blob/master/Framework/Utils/FileSystemFolder.vbs (https://github.com/GeertBellekens/Enterprise-Architect-VBScript-Library/blob/master/Framework/Utils/FileSystemFolder.vbs)
I'm sure you can do something similar in jscript
'let the user select a folder, optionally from a given starting path.
public function getUserSelectedFolder(startPath)
dim folder, shell
Set shell = CreateObject( "Shell.Application" )
if len(startPath) > 0 then
Set folder = shell.BrowseForFolder( 0, "Select Folder", 0,startPath)
else
Set folder = shell.BrowseForFolder( 0, "Select Folder", 0)
end if
if not folder is nothing then
set getUserSelectedFolder = New FileSystemFolder
getUserSelectedFolder.FullPath = folder.Self.Path
Session.Output "folder.Self.Path: " & folder.Self.Path
else
set getUserSelectedFolder = Nothing
end if
end function
Geert
-
Thanks a lot Geert for the quick response. BrowseForFolder was exactly what I was looking for!