Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Grab name of folder


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
--------------------


--
scantor145
------------------------------------------------------------------------
scantor145's Profile: http://www.excelforum.com/member.php...o&userid=14766
View this thread: http://www.excelforum.com/showthread...hreadid=383858

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Grab name of folder

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"
wrote
in message
...

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
--------------------


--
scantor145
------------------------------------------------------------------------
scantor145's Profile:
http://www.excelforum.com/member.php...o&userid=14766
View this thread:
http://www.excelforum.com/showthread...hreadid=383858



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
number grab David New Users to Excel 5 July 20th 06 10:45 PM
How to decide folder-depth or How to select more folders/subfolders (folder-tree) ? Subteam Excel Discussion (Misc queries) 2 May 7th 06 08:14 PM
how can I specific a folder with wildcard criteria and excel will import all the correct files in that folder? Raven Excel Discussion (Misc queries) 1 January 24th 06 03:28 PM
First Letters Grab Pitbull Excel Discussion (Misc queries) 6 January 6th 05 01:51 PM
Any way to grab a .csv file from a folder using Wildcards David Johnston Excel Programming 3 July 22nd 03 03:52 AM


All times are GMT +1. The time now is 01:12 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"