Skip to main content

Browse windows to select item

Hi Brain, 
 
How are you doing? can you help me with a bit of script? I'm trying to get browse window to select a file. I already found a bit of script that lets you select a folder, but i need to select the file. I'm having problems converting the script to let me select a file instead of a folder.
 
Function BrowseFolder() Dim oFolder, oFolderItem Dim oPath, oShell, strPath, item Dim msg As String
 Set oShell = CreateObject( "Shell.Application" ) Set oFolder = oShell.Namespace(17) Set oFolderItem = oFolder.Self strPath = oFolderItem.Path
 msg = "Select file "  Set oFolder = oShell.BrowseForFolder(0, msg, 1, strPath )
 If oFolder Is Nothing Then  BrowseFolder = ""  Exit Function End If
 Set oFolderItem = oFolder.Self oPath = oFolderItem.Path
 BrowseFolder = oPathEnd Function
Thanks again, 
Dino.

Brian Element Mon, 04/02/2018 - 11:50

Hi Dino, are you trying to select any file or an IDEA file?

What you are using only selects a folder but there are a few options to select a file or a special function to select an IDEA file, let me know which nd I will give you some examle code.

Brian

Dino Mon, 04/02/2018 - 13:31

Hi Brain, I'm trying to select a file for example on my desktop. It is a .XAF file (xml auditfile). IDEA has a plugin for it but not for the newest type (3.2). 
Do you also have some nowhow for working with xml files and the way to code the tags (XRDF file)? 
Thanks again. 

Brian Element Wed, 04/04/2018 - 07:34

Hi Dino, here is some code to select your file.  Sorry, I have never really used xml files so I can't help you.  If you have a maintenance contract with IDEA you should probably send them the queation as they can probalby help you.

 


Sub Main

	' Declare variables and objects.
	Dim filename As String	
	Dim obj As Object

	' Access the CommomDialogs object.
	Set obj = Client.CommonDialogs
	
		' Show the Open dialog box with the applied filters.
	
		filename = obj.FileOpen("","","XML Files (*.XML)|*.XML|All Files (*.*)|*.*||;")
	
		' Display the selected file name.
	
		MsgBox filename

	Set obj = Nothing

End Sub

Dino Wed, 04/04/2018 - 09:49

Hi Brain, 
It works like a charm, Thanks!
We have a support contract so I will try to contact them for some info. 

cthilton Fri, 03/29/2019 - 22:04

Is it possible for this file window to open to a specific folder, such as the Source Files folder of the current idea project i am working in?

Brian Element Fri, 04/05/2019 - 07:22

In reply to by cthilton

Yes it is, the second parameter allows you to say where you want the folder to open.  I have adapted the code above to open in the current project folder under the Source Files folder.


Sub Main

	' Declare variables and objects.
	Dim filename As String	
	Dim obj As Object

	' Access the CommomDialogs object.
	Set obj = Client.CommonDialogs
	
		' Show the Open dialog box with the applied filters.
		workfolder = Client.WorkingDirectory()
		filename = obj.FileOpen("",workfolder & "Source Files.ILB\*.*","XML Files (*.XML)|*.XML|All Files (*.*)|*.*||;")
	
		' Display the selected file name.
	
		MsgBox filename

	Set obj = Nothing

End Sub

PATKELL Fri, 05/14/2021 - 17:49

This it possible to write a script that allows the user to script an equation from a folder and insert that equation into a direct extraction
 
thanks