vba 目录选择方法2

今天又看到一个目录选择的方法,原来excel 2002一上,不需要调api了,

'Browse for a folder, using the Excel 2002 FileDialog
Sub BrowseForFolder()

Dim fdBrowser As FileDialog

'Get the File Dialog object
Set fdBrowser = Application.FileDialog(msoFileDialogFolderPicker)

With fdBrowser

'Initialize it
.Title = "Select Folder"
.InitialFileName = "c:\"

'Display the dialog
If .Show Then
MsgBox "You selected " & .SelectedItems(1)
End If
End With

End Sub


Powered by ScribeFire.

posted on 2007-06-05 17:08  BEW  阅读(1475)  评论(0编辑  收藏  举报