![]() |
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 |
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 |
All times are GMT +1. The time now is 11:23 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com