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 John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using wdDialogFileFind to return folders only

Status
Not open for further replies.

duGly

Technical User
Nov 13, 2006
52
US
I am using VBA with Word 2003. I am trying to use the wdDialogFileFind dialog to return a string indicating a folder name and path. I'm using the .Display method rather than the .Show method because I only want to return a string, not have the dialog actually do anything.

The problem is, wdDialogFileFind is really not the best tool for the job for the following reasons:

1. The wdDialogFileFind dialog shows folders and files. I want it to only show folders that the user can pick from.

2. I want the "File name:" text box to read "Folder name:".

3. I don't want the "Files of type:" combo box to display.

Furthermore, Word uses the perfect dialog for what I'm trying to do. If I choose Tools|Options|File Locations|Modify, it gives me the Modify Location dialog, which is exactly what I want. I can bring up the File Locations dialog (wdDialogToolsOptionsFileLocations) programmatically, but I can't seem to find the Modify Location dialog. I'm not even sure if it exists as a built-in dialog.

OK, long intro; here's my question:

1. Does the Modify Location dialog exist as a built-in dialog?

2. Can the wdDialogFileFind or any other dialog be modified to behave like the Modify Location dialog? Microsoft's documentation of the "Built-in Dialog Box Argument Lists" is so scant as to be nearly useless: it lists the arguments for each dialog, but gives no indication how each argument is used, what its data type is, what the built-in constants are, etc.

Thanks in advance for anyone who can help me with this.
 
And what about this ?
Function PickFolder(strStartDir As Variant) As String
Dim SA As Object, F As Object
Set SA = CreateObject("Shell.Application")
Set F = SA.BrowseForFolder(0, "Choose a folder", 0, strStartDir)
If (Not F Is Nothing) Then
PickFolder = F.Items.Item.Path
End If
Set F = Nothing
Set SA = Nothing
End Function

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
1. I do not believe so. It appears to be a dynamically modified Open dialog. The Modify commandbutton on wdDialogToolsOptionsFileLocations appears to internally modify the wdOpen dialog (with Folder name instead of File).

I have looked, and I can not see how you can get it programatically.

2. Ditto.

But I would be happy to be corrected by someone else.

Gerry
My paintings and sculpture
 
Thanks, PH and Gerry. I tried out your suggestion, PH, and it worked great.

In my searches of help files, however, I actually found exactly what I was looking for, which I believe is what wdDialogToolsOptionsFileLocations displays when Modify is clicked. It is the FileDialog object. Here is my code:
Code:
Public Sub FindFolder()[green]
'
' Variables:
'   strFolder = Folder selected by user.[/green]
    Dim strFolder$

    With Application.FileDialog(msoFileDialogFolderPicker)
        .AllowMultiSelect = False
        .ButtonName = "OK"
        .Title = "Select Parent Folder"
        If .Show = 0 Then Exit Sub
        strFolder = .SelectedItems(1)
    End With

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top