Grab name of folder

S

scantor145

Excel 2002 with Visual Basic 6.3

The code below allows me to select a desired folder, but I then need to
assign the name of that folder to a varibale. I'm at a loss right now.



Code:
--------------------
Sub GetAFolder()

With Application.FileDialog(msoFileDialogFolderPicker)
.InitialFileName = Application.DefaultFilePath & "\"
.Show
If .SelectedItems.Count = 0 Then
MsgBox "Canceled"
Else
MsgBox .SelectedItems(1)
End If
End With

End Sub
 
C

Chip Pearson

Try

Sub GetAFolder()
Dim FolderName As String
With Application.FileDialog(msoFileDialogFolderPicker)
.InitialFileName = Application.DefaultFilePath & "\"
.Show
If .SelectedItems.Count = 0 Then
MsgBox "Canceled"
Else
FolderName = .SelectedItems(1)
End If
End With

End Sub



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"scantor145"
in message
news:[email protected]...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top