Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Desktop in seldirdlg() gives error 1

Status
Not open for further replies.

button71

Programmer
Nov 8, 2006
69
AU
I have been using this function for years and never had a user select 'desktop'

This gives the error

Member PARENTFOLDER does not evaluate to an object

Line : FOR EACH item IN oBrowseObject.ParentFolder.Items

Code:
FUNCTION SelDirDlg
LPARAMETERS cDialogTitle, cStartingFolder, nBrowseFlags
*  Select a directory using the default browser dialog
*  Give a default title if none specified
IF TYPE('cDialogTitle') # 'C'
	cDialogTitle = 'Please select a folder:'
ENDIF
*  Default the start folder to an empty string;  if
*  you specify a starting folder, the browse is
*  anchored there, although you can override it with
*  the dialog's EditBox
IF TYPE('cStartingFolder') # 'C'
	cStartingFolder = ''
ENDIF
IF TYPE('nBrowseFlags') # 'N'
	* uses BROWSEINFO structure ulFlags values
	* by default, set BIF_RETURNONLYFSDIRS (1) and BIF_EDITBOX (16) and BIF_VALIDATE
	* to limit to returning directories, provide an edit box to let user enter a path,
	* and validate manually-entered paths
	*
	* ulFlags values:
	*	BIF_RETURNONLYFSDIRS	1
	*	BIF_DONTGOBELOWDOMAIN	2
	*	BIF_STATUSTEXT			4
	*	BIF_RETURNFSANCESTORS	8
	*	BIF_EDITBOX				0x10
	*	BIF_VALIDATE			0x20
	*	BIF_BROWSEFORCOMPUTER	0x1000
	*	BIF_BROWSEFORPRINTER	0x2000
	*	BIF_BROWSEFOREVERYTHING	0x4000
	nBrowseFlags = 32 + 16 + 1
ENDIF
LOCAL oBrowseObject, cPathToReturn, oShellObj
oShellObj = CREATEOBJ('Shell.Application')
cPathToReturn = ''
*	Get a Folder object
oBrowseObject = oShellObj.BrowseForFolder(0, ;
		cDialogTitle, ;
		nBrowseFlags, ;
		cStartingFolder)
*	Before I used the Items collection of the Folder object
*	to get a path;  it doesn't work if the directory is empty.
*	Instead, spin through the Items collection of the Parent
*	Folder and locate the item whose name matches the
*	Title property of the Folder object;  return that path
IF TYPE('oBrowseObject') = 'O' AND ! ISNULL(oBrowseObject)
	FOR EACH item IN oBrowseObject.ParentFolder.Items
		IF item.name == oBrowseObject.title
			cPathToReturn = Item.Path
			EXIT
		ENDIF
	ENDFOR
ENDIF
RETURN cPathToReturn

Anybody help here?

Regards

Bryan
 
If oBrowseObject.Self.Name="Desktop"
* Handle the issue
Endif
 
I used

Code:
IF oBrowseObject.Self.Name="Desktop"

	WshShell = CreateObject("WScript.Shell")

	cPathToReturn = WshShell.SpecialFolders(4)

	RETURN cPathToReturn
ENDIF

to open on the users desktop.

Thanks

William
 
Is it possible to open a browse window on Thumbnail view using the above code?

I open on a previously used path (folder) which contains images. Thumbnail view is always the first thing to do when the window opens.

Regards

Bryan
 
Brian,

I'm asked to register for that page. Without knowing whether that will give me the answer I find that rather expensive.

I already donate to Tek-Tips

Regards

Bryan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top